Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
50 lines (39 loc) · 1.01 KB

File metadata and controls

50 lines (39 loc) · 1.01 KB
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
/**
* Shows how to use chaining rather than the `serialize` method.
*/
"use strict";
var sqlite3 = require('sqlite3').verbose();
var db;
function createDb() {
console.log("createDb chain");
db = new sqlite3.Database('chain.sqlite3', createTable);
}
function createTable() {
console.log("createTable lorem");
db.run("CREATE TABLE IF NOT EXISTS lorem (info TEXT)", insertRows);
}
function insertRows() {
console.log("insertRows Ipsum i");
var stmt = db.prepare("INSERT INTO lorem VALUES (?)");
for (var i = 0; i < 10; i++) {
stmt.run("Ipsum " + i);
}
stmt.finalize(readAllRows);
}
function readAllRows() {
console.log("readAllRows lorem");
db.all("SELECT rowid AS id, info FROM lorem", function(err, rows) {
rows.forEach(function (row) {
console.log(row.id + ": " + row.info);
});
closeDb();
});
}
function closeDb() {
console.log("closeDb");
db.close();
}
function runChainExample() {
createDb();
}
runChainExample();
Morty Proxy This is a proxified and sanitized view of the page, visit original site.