Crates.io | sqlite-mumu |
lib.rs | sqlite-mumu |
version | 0.1.0 |
created_at | 2025-08-15 11:20:49.765328+00 |
updated_at | 2025-08-15 11:20:49.765328+00 |
description | sqlite-mumu is a plugin for the mumu ecosystem |
homepage | https://lava.nu11.uk |
repository | https://gitlab.com/tofo/postgres-mumu |
max_upload_size | |
id | 1796584 |
size | 66,433 |
SQLITE-MUMU sqlite-mumu is a SQLite plugin for the mumu runtime. It exposes a compact API to open a database, run parameterized SQL, stream results through mumu’s iterator pipeline, and close the connection.
TL;DR
TABLE OF CONTENTS
Prerequisites
Build Option A: with Makefile make
Option B: with Cargo cargo build --release
Artifacts (target/release):
Install (Linux) sudo make install This copies target/release/libmumusqlite.so to /usr/local/lib/ and runs ldconfig.
If you prefer a custom location, copy the built library there and ensure your loader can find it (see search order below).
In a mumu script or the REPL: extend("sqlite")
The loader looks for a library named:
Search order (first match wins):
When loaded, the plugin registers these functions in mumu:
3.1 sqlite:open Open (or create) a SQLite database and return a numeric connection handle.
Call handle = sqlite:open([path: ":memory:"]) handle = sqlite:open([path: "example.db"])
Arguments
Return
Notes
3.2 sqlite:query Run SQL (optionally parameterized) using an existing connection.
Minimal result = sqlite:query([db: handle, sql: "select 1 as x"])
With parameters result = sqlite:query([ handle: handle, sql: "insert into users(name, active) values (?, ?)", params: ["Ada", true] ])
Arguments (keyed array)
Return
3.3 sqlite:close Close a previously opened connection.
Call ok = sqlite:close([db: handle])
Arguments
Return
4.1 Create table, insert, select
extend("sqlite")
db = sqlite:open([path: ":memory:"])
_ = sqlite:query([db: db, sql: "create table users(id integer primary key, name text, active integer)"])
_ = sqlite:query([db: db, sql: "insert into users(name, active) values (?, ?)", params: ["Ada", 1]]) _ = sqlite:query([db: db, sql: "insert into users(name, active) values (?, ?)", params: ["Bob", 0]]) _ = sqlite:query([db: db, sql: "insert into users(name, active) values (?, ?)", params: ["Cyd", 1]])
rows = sqlite:query([db: db, sql: "select id, name, active from users order by id"])
slog(rows) ; prints each row as it is iterated (REPL-friendly)
_ = sqlite:close([db: db])
4.2 Parameterized updates
count = sqlite:query([ db: db, sql: "update users set active = ? where name = ?", params: [0, "Ada"] ]) slog(count) ; prints rows changed
4.3 NULLs and booleans
_ = sqlite:query([db: db, sql: "insert into flags(val) values (?)", params: [true]]) ; binds 1
_ = sqlite:query([db: db, sql: "insert into maybe_vals(v) values (?)", params: [_]]) ; binds NULL
; Reminder: using params: _ (a lone placeholder) means “no parameters”, not “one NULL”.
Row-producing statements (SELECT, PRAGMA, WITH) return an InkIterator of rows. Each row is a keyed array keyed by the column names reported by SQLite.
Example row shape { id: 1, name: "Ada", active: 1 }
SQLite type → mumu Value mapping
Because results are an InkIterator, they compose nicely with slog and other iterator-aware utilities in mumu.
Statement classification
Parameter conversion
Verbose logging
Thread-safety
Column names
Message: sqlite:query expects a keyed array argument
Message: sqlite:query: 'handle' (or 'db' or 'conn') missing or not int
Message: sqlite:query: invalid handle
Message: sqlite:query: prepare error / rows error / row error / execute error
BLOB values appear as “[BLOB]”
Loader can’t find the library