deno sqlite plugin 🌱

Bindings to rusqlite for deno.

Stability

UNSTABLE 🚨

This plugin will panic if anything goes slightly wrong. Probably don't use it in production just yet.

COMPATIBILITY

This plugin is tested against deno v0.35.0 🦕

Usage

Install Rust (I recommend rustup) and deno.

Build and run:

cargo build --release
deno --allow-plugin --allow-read=. tests/interface.js release

See interface.js for the full example.

When would I use this?

Use this plugin whenever you would embed an SQLite database into any other program. It's essentially just a wrapper around (another wrapper around) the actual SQLite C code.

deno-sqlite, which is awesome, works in browsers; this plugin does not. This plugin does allow you to work with SQLite databases from the filesystem with all the durability and performance SQLite provides. Wasm-based SQLite ports require you to load the entire database file into memory, operate on it, then save the whole thing back to disk again.

SQLite is very good. You might not always need a remote database like MySQL or Postgres. But if you do, check out deno_mysql or deno-postgres.

How does it work?

Query parameters are encoded to JSON text and sent from deno's JS runtime to the plugin. The plugin decodes the JSON then performs the query against SQLite using rusqlite. It then re-encodes the result as JSON and sends it back to JS-land.

SQLite's BLOB type is encoded using base64 for transmission via JSON and exposed in the deno interface as an ArrayBuffer. (It might be nice to use a binary serialisation format like CBOR instead of JSON to avoid the base64 encode/decode on either side.)

Licenses