How to open a export database file?
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.
Hello ! I wonder if you have found a solution ? I 'm using sql.js and need to export the user DB to a PHP server, thank you !
Hello ! I wonder if you have found a solution ? I 'm using sql.js and need to export the user DB to a PHP server, thank you !
Nope.