| Crates.io | sqlite-mumu |
| lib.rs | sqlite-mumu |
| version | 0.2.0-rc.4 |
| created_at | 2025-08-15 11:20:49.765328+00 |
| updated_at | 2025-10-12 03:32:18.865099+00 |
| description | sqlite-mumu is a plugin for the mumu ecosystem |
| homepage | https://lava.nu11.uk |
| repository | https://gitlab.com/tofo/sqlite-mumu |
| max_upload_size | |
| id | 1796584 |
| size | 65,476 |
A MuMu/Lava plugin to provide fast, native SQLite access with typed params, streaming result-sets, and friendly data-last ergonomics.
Repository: https://gitlab.com/tofo/sqlite-mumu
License: MIT OR Apache-2.0
Engine compatibility: core-mumu = 0.9.0-rc.4 (host builds; not intended for wasm)
sqlite:* functions to MuMu/LavaSELECT results via the core Iterator type (no giant in-memory buffers)Long, floats as Float)extend("sqlite")On native builds the plugin registers itself through the exported entrypoint Cargo_lock(...) so extend("sqlite") can load it at runtime.
sqlite:open([path, flags]) → handle:int
path — SQLite file path (e.g., "/tmp/app.db"; special SQLite URIs are allowed)flags — "ro" (read-only) · "rw" (read/write) · "rwc" (read/write create; default)sqlite:close([handle]) → bool
"handle" (and synonyms "db", "conn")true on success; errors if the handle is unknownConnections are stored internally as Arc<Mutex<rusqlite::Connection>>, ensuring safe, serialized access.
sqlite:query([handle, sql, params]) → Iterator | int
sql — SQL string (or a single-element StrArray)params — optional parameters as:
IntArray, FloatArray, StrArray, BoolArray, or MixedArray_ (Placeholder) maps to NULLSELECT/PRAGMA/WITH:
Iterator of rows as KeyedArrayINSERT/UPDATE/DELETE/DDL:
Int (rows changed) from SQLite’s executeType mapping (SQLite → MuMu per column):
NULL → PlaceholderINTEGER → LongREAL → FloatTEXT → SingleStringBLOB → SingleString("[BLOB]") (opaque marker)Type mapping (MuMu params → SQLite):
Int/Long/IntArray → integer bindsFloat/FloatArray → real bindsSingleString/StrArray → text bindsBool/BoolArray → 1/0 integer bindsMixedArray — element-wise mapping based on the abovePlaceholder → NULLStreaming: result rows are yielded on demand. Consume with any iterator-aware tool (e.g., slog, your own collectors, or array/flow helpers).
All functions use keyed arrays for clarity; handle key synonyms are accepted (handle, db, or conn).
sqlite:open([path:"/tmp/app.db", flags:"rwc"]) → 1000sqlite:query([handle:1000, sql:"SELECT 1 AS n", params:_]) → Iteratorsqlite:close([db:1000]) → trueError messages are explicit (e.g., "sqlite:query: prepare error: ...", "sqlite:open: 'path' field missing"). When the MuMu interpreter runs with --verbose (or LAVA_VERBOSE=1), the plugin prints extra diagnostics to stderr (e.g., row streaming traces).
extend("sqlite")
h = sqlite:open([path:"/tmp/example.db", flags:"rwc"])
// DDL / DML return changed-row counts
sqlite:query([handle:h, sql:"CREATE TABLE IF NOT EXISTS t(id INTEGER PRIMARY KEY, name TEXT)"])
sqlite:query([handle:h, sql:"INSERT INTO t(name) VALUES (?)", params:["Ada"]])
sqlite:query([handle:h, sql:"INSERT INTO t(name) VALUES (?)", params:["Ben"]])
// SELECT returns an Iterator of KeyedArray rows
rows = sqlite:query([handle:h, sql:"SELECT id, name FROM t WHERE id > ?", params:[0]])
// Stream to console (one row per poll tick)
slog(rows)
// Clean up
sqlite:close([handle:h])
// Parameter typing: arrays map directly to SQLite binds
h = sqlite:open([path:"/tmp/example.db"])
sqlite:query([handle:h, sql:"UPDATE t SET name = ? WHERE id = ?", params:["Eve", 1]])
sqlite:close([handle:h])
sqlite:open — returns Int handle; errors on invalid flags/path/open failuresqlite:query
SELECT/PRAGMA/WITH — returns Iterator of KeyedArray rowsInt rows changedsqlite:close — returns Bool(true) if the handle existed, errors otherwiseIterator exhaustion signals "NO_MORE_DATA" internally; helper functions (e.g., slog) handle this.
rusqlite; not intended for wasm.SELECT results are not fully materialized.Long vs Float).KeyedArray (insertion-order map).libsqlite3-sys with features = ["bundled"]); on Unix-likes it uses the system library by default.Issues and merge requests welcome at:
https://gitlab.com/tofo/sqlite-mumu
Please align changes with the MuMu core conventions:
Licensed under either of:
at your option.