samedi 5 septembre 2015

Connect to sqlite db from javascript host

I'm working on a chrome extension that uses native messaging. The host is written in JS and uses Node.js. Native messaging works fine but I can't connect the host with a local sqlite3 database. Used this: http://ift.tt/1k02D1Z project, but the connection to the host is always lost as soon as I use the db object.

Part of my host.js looks like this:

var fs = require('fs');

//database: require the sql.js file (tried with and without filetype)
var s = require('../sql');

var uInt8Array = new Uint8Array('../dat.db');
var db = new s.Database(uInt8Array);
var res = db.exec("SELECT set FROM data;"); 
//host gets unknown error and connection to extension is lost

My guess is that the db object isn't created at all. I tried: 1. Using other methods to open specific database 2. calling db.exec in a later stage - but it doesn't work whenever I call it 3. Using new s.Database() - but can't find any new db created

Any suggestions would be appreciated!

Aucun commentaire:

Enregistrer un commentaire