Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Node.js with a SQLite database (based on sample from
var sqlite3 = require('sqlite3').verbose();
var db = new sqlite3.Database('data/demodb01');
db.serialize(function() {"CREATE TABLE IF NOT EXISTS demo (runtime REAL)");"INSERT INTO demo (runtime) VALUES (?)", new Date().getTime());
db.each("SELECT runtime FROM demo", function(err, row) {
console.log("This app was run at " + row.runtime);
Copy link

koalahamlet commented Aug 5, 2014

@dalelane I'm currently getting this error when I try and run the file.

throw er; // Unhandled 'error' event
Error: SQLITE_CANTOPEN: unable to open database file

Copy link

vandenoever commented Oct 5, 2014

@ koalahamlet the database would be written to 'data/demodb01'. This fails if the directory 'data' does not exist.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment