Skip to content
This repository


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

SQLite bindings for Node.js

tree: 1c3e2b7244

Fetching latest commit…

Cannot retrieve the latest commit at this time

Node.js bindings for sqlite3


### `sqlite.openDatabaseSync(filename)`

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

The return value is the first (often only) result set.

### `DatabaseSync.close()`

Closes the database.


    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);


Install node.

`$` **`hg clone node-sqlite`**

`$` **`cd node_sqlite`**

`$` **`node-waf configure`**


`$` **`node-waf build`**


`$` **`node test.js`**
Something went wrong with that request. Please try again.