i am trying to create a Database with SQL.js by loading a sqlite file. This is the example given by the developer on the github site:
var fs = require('fs');
var SQL = require('sql.js');
var filebuffer = fs.readFileSync('test.sqlite');
// Load the db
var db = new SQL.Database(filebuffer);
This script uses the Node.js package fs, but i don`t want to use any server-side javascript. So i tried to do the following:
function loaddb(tr){
var fileList = tr.files;
var file = fileList[0];
db = new SQL.Database(file);
console.log(db);
}
The script is called, when a HTML-File-Input triggers the onchange event. I know that the file represents a real file and not just a null object, but i don`t know how to convert the file variable, so SQL.js would load it.
The Documentation states that i have to use a byte-array.
Is it even possible to create a byte array in client-side js and if so how do i do it ? Are there any other approaches when it comes to loading the file ?
Thanks in advance and sorry for any grammar mistakes, english is not my first language.
Aucun commentaire:
Enregistrer un commentaire