Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
node-sqlite3
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
俞永鹏
node-sqlite3
Commits
6a666dd9
Commit
6a666dd9
authored
Feb 28, 2011
by
Konstantin Käfer
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of
https://github.com/coolaj86/node-sqlite3
into coolaj86-master
parents
0bd387be
fae3d0fd
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
55 additions
and
0 deletions
+55
-0
simple-chaining.js
examples/simple-chaining.js
+55
-0
No files found.
examples/simple-chaining.js
0 → 100644
View file @
6a666dd9
/*
Shows how to use chaining rather than the `serialize` method
*/
(
function
()
{
"use strict"
;
require
(
'long-stack-traces'
);
var
sqlite3
=
require
(
'sqlite3'
).
verbose
(),
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 (?)"
),
i
;
for
(
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
();
}());
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment