Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Uncaught TypeError: must start with number, buffer, array or string #134

Open
ang3lx opened this issue Jan 25, 2016 · 0 comments
Open

Uncaught TypeError: must start with number, buffer, array or string #134

ang3lx opened this issue Jan 25, 2016 · 0 comments

Comments

@ang3lx
Copy link

ang3lx commented Jan 25, 2016

I've created a little script with sql.js documentation, but i'm unable to write buffer into a.db (Win)
console gives me error: "Uncaught TypeError: must start with number, buffer, array or string"
is that something regarding "var data = db.export();" function or is there something wrong in my code?

var fs = require("fs");
var remote = require('remote');
var SQL = remote.require('sql.js');
var file = "a.db"
var exists = fs.existsSync(file);

if(!exists) {
console.log("DB creation: "+file+ "");
fs.openSync(file, "w");
}

var filebuffer = fs.readFileSync(file);

// Load the db
var db = new SQL.Database(filebuffer);
// Run a query without reading the results
db.run("CREATE TABLE test (col1, col2);");
// Insert two rows: (1,111) and (2,222)
db.run("INSERT INTO test VALUES (?,?), (?,?)", [1,111,2,222]);

var data = db.export();
var buffer = new Buffer(data);
fs.writeFileSync(file, buffer);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant