deno sqlite plugin š±
Bindings to rusqlite for deno.
Stability
UNSTABLE :rotating_light:
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
- SQLite is public domain
- rusqlite is MIT
- Buffer to base64 implementation is MIT
- This packageās code is MIT