How to open a export database file?

Offen
#242 2 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

Bewertung

Schwierigkeit
3/5
Geschätzter Aufwand
1-2 Tage
Anfängerfreundlichkeit
38/100
Issue-Typ
Bug
Klarheit
Größtenteils klar
Aktivitätsstatus
Veraltet
Tech-Stack
javascript, php, sqlite
Bereich
backend, database

Rechercherichtung

Start with the JavaScript export and XMLHttpRequest loading snippets, then inspect how saveDb.php writes the posted data to sqlite.db. Verify that the fetched file contains the exported database bytes and that it can be passed to SQL.Database without the file error.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

I exported the database from memory and save it on server.The next time,when i re-open the exported file via XMLHttpRequest,it said the file is not a database file.How can I re-use the saved data?
The code to export and post to server:

        var data = db.export();
 	
 	db.close();
 	$.post("saveDb.php",{
 		data:data
 	},function(result){
	    console.log(result);
	});

On the server,I used the http_put_contents() to save the data to file "sqlite.db".
The code to load the saved db file is as below:

var xhr = new XMLHttpRequest();
xhr.open('GET', 'sqlite.db', true);
xhr.responseType = 'arraybuffer';
xhr.onload = function(e) {
	var uInt8Array = new Uint8Array(this.response);
	db = new SQL.Database(uInt8Array);
	//......
};
xhr.send();

Then it raise an error:Uncaught Error: file is not a database

Thank you.

Vorherrschende Sprache
JavaScript
Sterne
13.7k
Forks
1.1k
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus sql-js/sql.js

Alle Issues in sql-js/sql.js

Ähnliche Issues

Weitere Issues zu JavaScript

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.