Skip to content

Instantly share code, notes, and snippets.

@bbeamer
Last active August 29, 2015 14:26
Show Gist options
  • Save bbeamer/36e3295a9dba9dffebc9 to your computer and use it in GitHub Desktop.
Save bbeamer/36e3295a9dba9dffebc9 to your computer and use it in GitHub Desktop.
Read sqlite database using Sqlite.jsm module.
var {Cc, Ci, Cu} = require("chrome");
Cu.import("resource://gre/modules/Sqlite.jsm");
Cu.import("resource://gre/modules/Task.jsm");
Task.spawn(function* () {
let db = yield Sqlite.openConnection({ path: filePath});
try {
// query to select all cols where plate attribute lives
let row = yield db.execute(
"SELECT plate FROM 'myTable'");
// print out all plates
for(i=0; i < row.length; i++)
{
result = row[i];
console.log("Car plate :"+ i +" : "+ result.getResultByIndex(0));
}
}
finally {
yield db.close();
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment