Version0.16.2Verifiednot yet verifiedLicenseBSD-3-Clause

sigil-sqlite

SQLite database bindings for Sigil

Report a bug or suggest a feature
Readme

sigil-sqlite

SQLite database bindings for Sigil.

Embeddable SQLite access backed by the SQLite amalgamation compiled in-tree. Suitable for application data, local caches, and anywhere a full relational database is overkill.

Modules

ModulePurpose
(sigil sqlite)SQLite database bindings (low + high API)

API summary

Database

ProcedurePurpose
sqlite-openOpen database (or ":memory:")
sqlite-closeClose a database handle
sqlite-execExecute a SQL string (DDL, simple queries)
call-with-databaseOpen + run a proc + close, with cleanup

Prepared statements

ProcedurePurpose
sqlite-prepareCompile a SQL statement
sqlite-bindBind a parameter (1-based index)
sqlite-stepAdvance: 'row, 'done, or #f
sqlite-resetReset a statement to its initial state
sqlite-finalizeFree a statement

Column access

ProcedurePurpose
sqlite-column-countNumber of columns in the current row
sqlite-column-nameColumn name by 0-based index
sqlite-columnColumn value by 0-based index

Database info

ProcedurePurpose
sqlite-last-insert-rowidrowid of the last insert
sqlite-changesRows changed by the last statement
sqlite-errmsgLast error message
Read the rest

High-level helpers

ProcedurePurpose
sqlite-queryRun query; return all rows as alists
sqlite-query-rowRun query; return first row or #f
sqlite-runRun INSERT/UPDATE/DELETE with parameters

Predicates

ProcedurePurpose
sqlite-db?SQLite database handle predicate
sqlite-stmt?Prepared statement predicate

System prerequisites

None beyond a working C toolchain. The SQLite amalgamation (vendor/sqlite3.c + vendor/sqlite3.h) is vendored and compiled in-tree with these build flags:

  • -DSQLITE_THREADSAFE=0
  • -DSQLITE_OMIT_LOAD_EXTENSION
  • -DSQLITE_ENABLE_FTS5

Dependencies

  • sigil-stdlib

Build

sigil deps install
sigil build
sigil test --report

The first build compiles the SQLite amalgamation (one large translation unit) plus native/sqlite.c. Subsequent builds hit the cache.

Usage

(import (sigil sqlite))

(call-with-database "app.db"
  (lambda (db)
    (sqlite-exec db "CREATE TABLE IF NOT EXISTS users
                       (id INTEGER PRIMARY KEY, name TEXT)")
    (sqlite-run db "INSERT INTO users (name) VALUES (?)" "Alice")
    (sqlite-query db "SELECT * FROM users")))
;; => (((id . 1) (name . "Alice")))

License

BSD-3-Clause.

Vendored SQLite (under vendor/) is public domain. See vendor/sqlite3.c for the SQLite blessing.

Clone

$ git clone https://codeberg.org/sigil/sigil-sqlite

Releases

v0.16.2 — latest by version, released 14 Jul 2026

All releases — 5 tags in this repository.

Source

Browse the latest source

One page per file, and every line has a permalink.

Recent commitsAtom

The last 20 commits keep a page here. Everything older lives in the clone.