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
09b55954
Commit
09b55954
authored
Feb 28, 2011
by
Konstantin Käfer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
match code formatting
parent
6a666dd9
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
31 deletions
+26
-31
simple-chaining.js
examples/simple-chaining.js
+26
-31
No files found.
examples/simple-chaining.js
View file @
09b55954
/*
/**
Shows how to use chaining rather than the `serialize` method
* Shows how to use chaining rather than the `serialize` method.
*/
*/
(
function
()
{
"use strict"
;
"use strict"
;
require
(
'long-stack-traces'
);
var
sqlite3
=
require
(
'sqlite3'
).
verbose
();
var
db
;
var
sqlite3
=
require
(
'sqlite3'
).
verbose
(),
function
createDb
()
{
db
;
function
createDb
()
{
console
.
log
(
"createDb chain"
);
console
.
log
(
"createDb chain"
);
db
=
new
sqlite3
.
Database
(
'chain.sqlite3'
,
createTable
);
db
=
new
sqlite3
.
Database
(
'chain.sqlite3'
,
createTable
);
}
}
function
createTable
()
{
function
createTable
()
{
console
.
log
(
"createTable lorem"
);
console
.
log
(
"createTable lorem"
);
db
.
run
(
"CREATE TABLE IF NOT EXISTS lorem (info TEXT)"
,
insertRows
);
db
.
run
(
"CREATE TABLE IF NOT EXISTS lorem (info TEXT)"
,
insertRows
);
}
}
function
insertRows
()
{
function
insertRows
()
{
console
.
log
(
"insertRows Ipsum i"
);
console
.
log
(
"insertRows Ipsum i"
);
var
stmt
=
db
.
prepare
(
"INSERT INTO lorem VALUES (?)"
),
var
stmt
=
db
.
prepare
(
"INSERT INTO lorem VALUES (?)"
);
i
;
for
(
i
=
0
;
i
<
10
;
i
++
)
{
for
(
var
i
=
0
;
i
<
10
;
i
++
)
{
stmt
.
run
(
"Ipsum "
+
i
);
stmt
.
run
(
"Ipsum "
+
i
);
}
}
stmt
.
finalize
(
readAllRows
);
stmt
.
finalize
(
readAllRows
);
}
}
function
readAllRows
()
{
function
readAllRows
()
{
console
.
log
(
"readAllRows lorem"
);
console
.
log
(
"readAllRows lorem"
);
db
.
all
(
"SELECT rowid AS id, info FROM lorem"
,
function
(
err
,
rows
)
{
db
.
all
(
"SELECT rowid AS id, info FROM lorem"
,
function
(
err
,
rows
)
{
rows
.
forEach
(
function
(
row
)
{
rows
.
forEach
(
function
(
row
)
{
console
.
log
(
row
.
id
+
": "
+
row
.
info
);
console
.
log
(
row
.
id
+
": "
+
row
.
info
);
});
});
closeDb
();
closeDb
();
});
});
}
}
function
closeDb
()
{
function
closeDb
()
{
console
.
log
(
"closeDb"
);
console
.
log
(
"closeDb"
);
db
.
close
();
db
.
close
();
}
}
function
runChainExample
()
{
function
runChainExample
()
{
createDb
();
createDb
();
}
}
runChainExample
();
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