0
var db; //global variable $(document).ready(function () { // This is the recommended code for a Web page to download // an sqlite3 database: var xhr = new XMLHttpRequest(); xhr.open('GET', '/PathTo/Database.db', true); xhr.responseType = 'arraybuffer'; xhr.onload = function (e) { var uInt8Array = new Uint8Array(this.response); db = new SQL.Database(uInt8Array); // My code here fNowUseDownloadedDatabase(); }; xhr.send(); } function fNowUseDownloadedDatabase() { // Remember, db is a global variable. var a = db.exec("SELECT 'name', 'sql' FROM 'sqlite_master' WHERE type='table';"); var iLen = a.length; var i = 0; for (i = 1; i < iLen; i++) { console.log(a[i]); } } 

Instead of having 3 tables, the database has none. I know the path to the database is correct, otherwise I'd get a 404 error. Also, if I pass db into my fNowUseDownloadedDatabase function, it is an empty database. But on the server it has data. Somehow it is being downloaded with data but then replaced by an empty new database. Why not?

2

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.