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
c380ceb5
Commit
c380ceb5
authored
Mar 29, 2010
by
Orlando Vazquez
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update README
parent
f6165b41
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
58 additions
and
6 deletions
+58
-6
.gitignore
.gitignore
+0
-3
README.md
README.md
+58
-3
No files found.
.gitignore
View file @
c380ceb5
build/
build/
README.html
test.db
.lock-wscript
.lock-wscript
speedtest.db
sqlite3_bindings.node
sqlite3_bindings.node
README.md
View file @
c380ceb5
...
@@ -6,8 +6,16 @@ node-sqlite - Asynchronous SQLite3 driver for Node.js
...
@@ -6,8 +6,16 @@ node-sqlite - Asynchronous SQLite3 driver for Node.js
SYNOPSIS
SYNOPSIS
--------
--------
High-level Driver
=================
High-level bindings are provide a simple interface to SQLite3. They should be
fast enough for most purposes, but if you absolutely need more performance,
the low level drivers are also straight-forward to use, but require a few
additional steps.
var sys = require('sys'),
var sys = require('sys'),
sqlite = require('
./
sqlite');
sqlite = require('sqlite');
var db = new sqlite.Database();
var db = new sqlite.Database();
...
@@ -16,7 +24,7 @@ SYNOPSIS
...
@@ -16,7 +24,7 @@ SYNOPSIS
db.open("lilponies.db", function () {
db.open("lilponies.db", function () {
var colour = 'pink';
var colour = 'pink';
var sql = 'SELECT name FROM ponies WHERE
tail
_colour = ?';
var sql = 'SELECT name FROM ponies WHERE
hair
_colour = ?';
// bindings list is optional
// bindings list is optional
...
@@ -35,6 +43,52 @@ SYNOPSIS
...
@@ -35,6 +43,52 @@ SYNOPSIS
});
});
});
});
Low-level Driver
================
The low-level bindings directly interface with the SQLite C API. The API
approximately matches the SQLite3 API when it makes sense. Some deviations
from the API have been made to improve performance.
var sys = require('sys'),
sqlite = require('sqlite_bindings');
var db = new sqlite.Database();
// open the database for reading if file exists
// create new database file if not
db.open("lilponies.db", function () {
var colour = 'pink';
var sql = 'SELECT name FROM ponies WHERE hair_colour = ?';
var ponies = [];
// The prepare method will try to prefetch one row of results, so that
// if there are no rows we can avoid having to make two trips into the
// thread-pool.
// If `statement` and didn't have any variable place-holders to bind
// and doesn't evaluate to true, then it means the statement
// executed successfully but returned no rows (think INSERT's).
db.prepare(sql, function (error, statement) {
if (error) throw error;
statement.bind(0, 'pink', function () {
// call step once per row result
statement.step(function (row) {
if (!row) {
// end of rows
}
// do some stuff
// call statement.step() again for next row
});
});
});
});
DESCRIPTION
DESCRIPTION
-----------
-----------
...
@@ -54,7 +108,8 @@ This SQLite interface is incompatible with verison 2.
...
@@ -54,7 +108,8 @@ This SQLite interface is incompatible with verison 2.
SQLite's synchronous nature is fundamentally incompatible with a non-blocking
SQLite's synchronous nature is fundamentally incompatible with a non-blocking
system such as Node. To get around this synchronous calls happen within Node's
system such as Node. To get around this synchronous calls happen within Node's
libeio thread-pool, in a similar manner to how POSIX calls are currently made.
libeio thread-pool, in a similar manner to how POSIX calls are currently made.
This is exposed to JavaScript in the form of Database and Statement objects.
SQLite's serialized threading mode is used to make sure we use SQLite safely.
See http://www.sqlite.org/threadsafe.html for more info.
The author is aware that SQLite ships with an asynchronous interface. This
The author is aware that SQLite ships with an asynchronous interface. This
interface however lacks the necessariy notification mechanism to alert the
interface however lacks the necessariy notification mechanism to alert the
...
...
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