Skip to content
SQLite JavaScript client.
JavaScript TypeScript Shell
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.

SQLite client for JavaScript.

See for a general overview.


  • yarn add sqlite-mpi-client-js
    • Or: npm install --save sqlite-mpi-client-js

IO Providers

You also need to install an IO provider.


See ./test/all for detailed usage.

Get a file ref

// Note: Example is for Node.js.
const {smpi} = require("sqlite-mpi-client-js");
const iop = require("smpi-iop-node-ffi");

const c = smpi.newClient(iop);
const f = c.newFileRef("/tmp/db-file.sqlite");

Write transactions

  • There is only one active write transaction at a time per SQLite file.

    • This applies at an OS level, for all processes.
  • Write tx requests will queue when there is an active outstanding write tx.

    • Queued write tx requests will resolve in First In First Out (FIFO) manner.
    • When the promise returned from f.getWriteTx() resolves, the wtx is active.
const wtx = await f.getWriteTx();

// `q` can be a read or write with write txs.
await wtx.q("SELECT 1+1");

await"SELECT 1+1");

await wtx.write("INSERT ...");

await wtx.commit();
// await wtx.rollback();

Read transactions

  • Read transactions are concurrent; you can have many read transactions active and reading from the same database file.
const rtx = await f.getReadTx();

// `q` must be a read.
await rtx.q("SELECT 1+1");

await"SELECT 1+1");

// No writes.
// await tx.write("INSERT ...");

await rtx.commit();
// await rtx.rollback();


const wtx = await f.getWriteTx();

// Index based.
await wtx.write("INSERT INTO t1 (b) VALUES (?), (?)", [1, 2]);
await wtx.write("INSERT INTO t1 (b) VALUES (?1), (?2)", [3, 4]);

// Key based.
await wtx.write("INSERT INTO t1 (b) VALUES (:x), (:y)", {x: 1, y: 2});
await wtx.write("INSERT INTO t1 (b) VALUES (@x), (@y)", {x: 1, y: 2});
await wtx.commit();


  • SQLite WAL mode is always on; you can not turn it off.
  • Reads are concurrent, writes queue.
You can’t perform that action at this time.