Last active
August 29, 2015 14:26
-
-
Save bbeamer/36e3295a9dba9dffebc9 to your computer and use it in GitHub Desktop.
Read sqlite database using Sqlite.jsm module.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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