sql-js / sql-js/sql.js

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.

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

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.

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
  3. Forke das Repository und arbeite in einem Branch.
  4. Öffne einen Pull Request, der die Issue-Nummer nennt.

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.

Bewertung

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

Neue Issues direkt in Ihr Postfach

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