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
651cf679
Commit
651cf679
authored
Dec 09, 2009
by
Eric Fredricksen
Committed by
Eric Fredricksen
Dec 09, 2009
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Tidy up a little
parent
1c3e2b72
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
101 deletions
+7
-101
README
README
+7
-74
compiloop.js
compiloop.js
+0
-27
No files found.
README
View file @
651cf679
Node.js bindings for sqlite3
============================
SQLite3 bindings for Node.js
============================
=
Functions
-------------------
The code and some documentation live at http://code.google.com/p/node-sqlite/
### `sqlite.openDatabaseSync(filename)`
The two files required to use these bindings are sqlite.js and
build/default/sqlite3_bindings.node. Put this directory in your
NODE_PATH or copy those two files where you need them.
Returns a `DatabaseSync` object representing the sqlite3 database with
given filename.
### `DatabaseSync.query(sql [,bindings] [,callback])`
Executes the query `sql`, with variables bound from `bindings`. The
variables can take the form `?` or `?NNN` where `NNN` is a number, in which
case `bindings` should be an array of values, or the form `$VVV` where
`VVV` is an identifier, in which canse `bindings` should be an object
with keys matching the variable names.
If provided the `callback` is called with a number of arguments equal
to the number of statements in the query. Each argument is a result
set which is an array of objects mapping column names to values.
Each result set `r` also has these accessors:
- **`r.rowsAffected`** is the number of rows affected by an `UPDATE` query.
- **`r.insertId`** is the `ROWID` of the an `INSERT` query
- **`r.rows.length`** (also just `r.length`) is the number of rows in a
`SELECT` result
- **`r.all`** is an array of result sets, one for each statement in the
query
The return value is the first (often only) result set.
### `DatabaseSync.close()`
Closes the database.
Example
--------
var sqlite = require("./sqlite");
var db = new sqlite.Db("test.db");
db.query("INSERT INTO test (column) VALUES ($value)", {$value: 10});
db.query("SELECT column FROM test WHERE rowid<?", [5], function (rows) {
process.assert(rows[0].column == 10);
});
db.query("UPDATE test SET column=20; SELECT column FROM test;",
function (update, select) {
assert(update.count == 1);
assert(select[0].column == 20);
});
db.close();
Install
-------
Install node. http://nodejs.org/
`$` **`hg clone https://node-sqlite.googlecode.com/hg/ node-sqlite`**
`$` **`cd node_sqlite`**
`$` **`node-waf configure`**
Build
-----
`$` **`node-waf build`**
Test
----
`$` **`node test.js`**
(c) 2009 Eric Fredricksen - Permissive license terms at top of sqlite.js
compiloop.js
deleted
100644 → 0
View file @
1c3e2b72
var
sys
=
require
(
"sys"
);
function
handler
(
curr
,
prev
)
{
sys
.
puts
(
"Handling"
);
sys
.
puts
(
"the current mtime is: "
+
curr
.
mtime
);
sys
.
puts
(
"the previous mtime was: "
+
prev
.
mtime
);
sys
.
exec
(
"clear;rm -f test.db; node-waf build && node test.js"
);
}
sys
.
puts
(
JSON
.
stringify
(
process
.
ARGV
));
for
(
f
in
process
.
ARGV
)
{
f
=
process
.
ARGV
[
f
]
sys
.
puts
(
"Watching "
+
f
);
process
.
watchFile
(
f
,
handler
);
}
//var tcp = require("tcp");
//var server = tcp.createServer();
//server.listen(7000, "localhost");
for
(;;)
{
sys
.
exec
(
"sleep 1"
).
wait
();
}
//var p = new process.Promise();
//p.wait();
\ No newline at end of file
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