db.serialize(function executeSelect() { db.all( getUserDataStatement, { $sessionID: sessionID }, function queryExecuted(error, providerDisplayNameArray) { userData.providers = providerDisplayNameArray; callback(error, userData); } ); });
function createDB() { if (!fs.existsSync(dbFile)) { jfsdb.serialize(function() { jfsdb.run("CREATE TABLE jottafiles (filepath TEXT, md5hash TEXT, size INTERGER, modified INTEGER)"); jfsdb.run("CREATE INDEX ix_jottafiles ON jottafiles (filepath)"); }); } }
db.serialize(function() { db.run("CREATE TABLE lorem (info TEXT)"); var stmt = db.prepare("INSERT INTO lorem VALUES (?)"); for (var i = 0; i < 10; i++) { stmt.run("Ipsum " + i); } stmt.finalize(); db.each("SELECT rowid AS id, info FROM lorem", function(err, row) { console.log(row.id + ": " + row.info); }); });
db.serialize(() => { db.exec(schema) done() })
db.serialize(() => { db.run(`CREATE TABLE IF NOT EXISTS ${table_name} (title TEXT)`); db.run(`INSERT INTO ${table_name} VALUES (?)`, title); db.each(`SELECT rowid AS id, title FROM ${table_name}`, function(err, row) { console.log(row.id + ": " + row.title); }); });
function updateDatabase() { db.serialize(() => { db.run('UPDATE main_counter SET counter = ?', counter); db.run('INSERT OR IGNORE INTO statistics ( date, count ) VALUES ( date("now", "localtime"), ? )', daily); db.run('UPDATE statistics SET count = ? WHERE date = date("now", "localtime")', daily); for (const sound of sounds) { db.run('UPDATE sounds SET count = ? WHERE id = ?', sound.count, sound.id); } }); }
db.serialize(() => { const sql = ` CREATE TABLE IF NOT EXISTS articles (id integer primary key, title, content TEXT) `; db.run(sql); });
// This just stores the db in memory. // In an actual system you probably wouldn't have the full db initialization // script run each time the server is started, but this is an example and I am // just creating the database in memory each time the server starts. // Initialize the database db.serialize(function() { db.run("CREATE TABLE IF NOT EXISTS UserNames (name CHAR(20))"); db.run("INSERT INTO UserNames (name) VALUES (?)", "Bob"); db.run("INSERT INTO UserNames (name) VALUES (?)", "Joe"); db.run("INSERT INTO UserNames (name) VALUES (?)", "Steve"); });
db.serialize(() => { const sql = ` CREATE TABLE IF NOT EXISTS articles (id integer primary key, title, content TEXT) `; db.run(sql); });
// This just stores the db in memory. // In an actual system you probably wouldn't have the full db initialization // script run each time the server is started, but this is an example and I am // just creating the database in memory each time the server starts. // Initialize the database db.serialize(function() { db.run("CREATE TABLE IF NOT EXISTS UserNames (name CHAR(20))"); db.run("INSERT INTO UserNames (name) VALUES (?)", "Bob"); db.run("INSERT INTO UserNames (name) VALUES (?)", "Joe"); db.run("INSERT INTO UserNames (name) VALUES (?)", "Steve"); });
db.serialize(() => { const sql = ` CREATE TABLE IF NOT EXISTS articles (id integer primary key, title, content TEXT) `; db.run(sql); });
db.serialize(function executeInsert() { db.run( insertStatement, { $sessionID: sessionID, $providerName: providerName, $displayName: displayName, $accessToken: accessToken }, callback ); });
db.serialize(function executeDelete() { db.run( deleteStatement, { $sessionID: sessionID, $providerName: providerName }, callback ); });
// This just stores the db in memory. // In an actual system you probably wouldn't have the full db initialization // script run each time the server is started, but this is an example and I am // just creating the database in memory each time the server starts. // Initialize the database db.serialize(function() { db.run("CREATE TABLE IF NOT EXISTS UserNames (name CHAR(20))"); db.run("INSERT INTO UserNames (name) VALUES (?)", "Bob"); db.run("INSERT INTO UserNames (name) VALUES (?)", "Joe"); db.run("INSERT INTO UserNames (name) VALUES (?)", "Steve"); });
// This just stores the db in memory. // In an actual system you probably wouldn't have the full db initialization // script run each time the server is started, but this is an example and I am // just creating the database in memory each time the server starts. // Initialize the database db.serialize(function() { db.run("CREATE TABLE IF NOT EXISTS UserNames (name CHAR(20))"); db.run("INSERT INTO UserNames (name) VALUES (?)", "Bob"); db.run("INSERT INTO UserNames (name) VALUES (?)", "Joe"); db.run("INSERT INTO UserNames (name) VALUES (?)", "Steve"); });