Skip to content
SQLite bindings for Node.js http://grumdrig.github.com/node-sqlite/
JavaScript C++ PHP Python Shell
Find file
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
.hgignore
README
compiloop.js
compiloop.py
sqlite.js
sqlite3_bindings.cc
sqlite3_bindings.node
test.js
wscript

README

Node.js bindings for sqlite3
============================

Functions
-------------------

### `sqlite.openDatabaseSync(filename)`

Returns an 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 an argument for each
statement in the query. Each argument is an array of objects mapping
column names to values. 

Each callback argument `rows` also has these properties 

- **`rows.count`** is the number of rows affected by the query. 
- **`rows.rowid`** is the `ROWID` of the last `INSERT` command

Within the callback, `this` is an array of all such arrays, with a
`count` property giving the total number of rows affected. That same
`this` object is returned by `query`.

### `sqlite.Db.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`**
Something went wrong with that request. Please try again.