This repository was archived by the owner on Nov 22, 2026. It is now read-only.
Repository navigation
mojo-sqlite v0.1.0
mojo-sqlite v0.1.0
Released: 2026-10-21 · Commit: 6798b4c · Previous: first release
What it does
SQLite for Mojo that returns the same rows as Python's sqlite3, byte for byte, and
runs 2.7× faster on inserts and 4× to 5.5× faster on scans. It loads the system
libsqlite3.so.0 at run time, so it needs no linker flags.
from sqlite import Database
def main() raises:
var db = Database("jobs.db")
var q = db.prepare("SELECT id, cmd FROM jobs WHERE prio >= ?")
q.bind(1, 10)
while q.step():
print(q.int(0), q.text(1))Highlights
DatabaseandStatement: prepare once, bind, step, reset, transactions, typed reads.- Every SQLite value type: integers, floats, text, BLOBs, NULL; parameters by position
or by name (:prio,@prio,$prio). text_view()andblob_view()read in place from sqlite's buffer, with no copy.- Errors carry sqlite's own message:
sqlite: UNIQUE constraint failed: u.k (rc 19). - Docs in
docs/, a skill file for coding agents inskills/mojo-sqlite/SKILL.md.
Apache-2.0.
Changes
First public release, no earlier version.
Verified
| Check | Result |
|---|---|
oracle: every tests/cases/*.sql through this library and Python sqlite3 |
identical on 39 statements, floats compared bit for bit, BLOBs as hex |
tests/api.mojo: lifetimes, bind slots, empty BLOB vs NULL, named parameters, errors, reuse |
pass |
scripts/ci.sh on a pristine Ubuntu 24.04 VM, sqlite 3.45.1 |
PASS all |
| same on Arch Linux, sqlite 3.54.0 | PASS all |
tests/bench.mojo vs Python, 200k inserts + scan, 3 runs |
insert 80 to 84 ms vs 216 to 226 ms; scan 25 ms (18 ms with text_view) vs 98 to 99 ms |
Known limits
- Linux only: the library is loaded as
libsqlite3.so.0. - One connection per
Database; do not share aDatabaseorStatementacross threads. - No Mojo package registry yet: install from source, a precompiled
.mojoc, or by vendoring.
Upgrade / run
git clone https://github.com/amarbaro/mojo-sqlite && cd mojo-sqlite && uv sync
mojo run -I src examples/quickstart.mojo
Commits
6798b4cci: GitHub Actions runs scripts/ci.sh, badge, Apache-2.0 in pyprojecte4b3eedfeat(sqlite): BLOBs and named parameters4d2ed99feat(sqlite): SQLite bindings for Mojo, oracle-checked against Python sqlite3