Skip to content

Instantly share code, notes, and snippets.

@efleming969
Created February 24, 2017 18:50
Show Gist options
  • Save efleming969/2858b3d509707f3534f9ac6f4622c790 to your computer and use it in GitHub Desktop.
Save efleming969/2858b3d509707f3534f9ac6f4622c790 to your computer and use it in GitHub Desktop.
nodejs-training-database
var Sqlite = require( "sqlite3" ).verbose()
var db = new Sqlite.Database( "members.db" )
db.serialize( function() {
db.run("DROP TABLE IF EXISTS members" )
db.run("CREATE TABLE members(id varchar(255), name varchar(255), default_plan varchar(255))")
db.run("INSERT INTO members(id, name, default_plan) VALUES('1', 'john', '')")
console.log( "databse was setup!" )
var sql1 = "SELECT * FROM members WHERE id = ?"
db.get( sql1, [ "1" ], function(err, member) {
console.log( member )
} )
// db.all( somesql, [], function(err, rows) {} )
} )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment