odin-sqlite-strict: an idiomatic wrapper around a minimal, statically-linked SQLite build
Repo: github.com/sdicker8/odin-sqlite-strict
A bit of background first: I’m a retired data scientist, 30+ years of programming behind me across a lot of languages. SQLite was my go-to whenever a project needed data persistence rather than a dataframe in memory - small footprint and zero setup. I discovered Odin recently and have really enjoyed working in it. An SQLite wrapper seemed like a good first real project.
A few things about the design, if you’re deciding whether it’s worth a look:
- Strict by default. Every connection enforces foreign keys, treats double quotes as identifier quotes only (so a mistyped column name is an error instead of a string), and reports which constraint failed. The README recommends
STRICTtables, which make SQLite reject values of the wrong type. - Errors you can act on. Everything that can fail returns an
Errorthat works withor_return, and the message from a failure is still there after the deferred rollback has cleaned up.executerefuses to run if the parameter count doesn’t match the placeholders, rather than binding NULL. - Thin and auditable.
bindings.odinmirrors the C API subset the package uses 1:1, with no ownership decisions in it.sqlite.odinsits on top. - Built against a minimal SQLite (no FTS/RTREE/JSON/extension loading).
lib_build/reproduces that build from source on Linux and Windows and checks the compiled-in options afterwards rather than trusting the flags. You can also link your own SQLite 3.37+. defer-friendly transactions, plus an optional reflection-based row scanner (row_layout/scan_row) alongside the explicitcolumn_*API.
The README explains the reasoning behind each of these.
I didn’t look at other Odin SQLite bindings until this one was mostly written. I wanted to work through the design myself first.
Full disclosure: I used an AI assistant heavily, but I reviewed and directed every design decision and every line.
Tests and the example pass on Linux and Windows (one known upstream odin test issue on Windows is noted in the README). macOS is untried, so if anyone on a Mac is willing to try the build script, I’d appreciate the data point.
Feedback, issues, and PRs welcome. CONTRIBUTING.md mostly asks that you open an issue first for anything non-trivial, so we’re not talking past each other.