Commita266009dRecorded24 Apr 2026Repositorysigil-sqlite
Extract sigil-sqlite from sigil monorepo
Message
Initial standalone release. Scaffolding (README.md, .gitignore, manifest.scm, dev-redirects.sgl), package.sgl bumped to 0.13.1 with url pointing at the new repo and sigil-stdlib pinned via from-git.
Native compile step for native/sqlite.c now wraps flags in (with-sigil-c-flags ...) and drops the monorepo-relative ../sigil-lib/* include-dirs; the vendored SQLite amalgamation compile step is unchanged.
test/test.sgl renamed to test/test-sqlite.sgl to match the test-*.sgl auto-discovery convention used by sigil test.
Changed
.gitignore | 2 ++
README.md | 112 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
dev-redirects.sgl | 6 ++++++
manifest.scm | 7 +++++++
package.sgl | 17 ++++++++---------
sigil.lock | 8 ++++++++
test/main.c | 2 +-
test/{test.sgl => test-sqlite.sgl} | 0
8 files changed, 144 insertions(+), 10 deletions(-)Diff
.gitignoreadded
@@ -0,0 +1,2 @@
+1
build/+2
.sigil/README.mdadded
@@ -0,0 +1,112 @@
+1
# sigil-sqlite+2
+3
SQLite database bindings for [Sigil](https://codeberg.org/sigil/sigil).+4
+5
Embeddable SQLite access backed by the SQLite amalgamation compiled+6
in-tree. Suitable for application data, local caches, and anywhere a+7
full relational database is overkill.+8
+9
## Modules+10
+11
| Module | Purpose |+12
|-------------------|-------------------------------------------|+13
| `(sigil sqlite)` | SQLite database bindings (low + high API) |+14
+15
## API summary+16
+17
### Database+18
+19
| Procedure | Purpose |+20
|-----------------------------|---------------------------------------------|+21
| `sqlite-open` | Open database (or `":memory:"`) |+22
| `sqlite-close` | Close a database handle |+23
| `sqlite-exec` | Execute a SQL string (DDL, simple queries) |+24
| `call-with-database` | Open + run a proc + close, with cleanup |+25
+26
### Prepared statements+27
+28
| Procedure | Purpose |+29
|-----------------------------|---------------------------------------------|+30
| `sqlite-prepare` | Compile a SQL statement |+31
| `sqlite-bind` | Bind a parameter (1-based index) |+32
| `sqlite-step` | Advance: `'row`, `'done`, or `#f` |+33
| `sqlite-reset` | Reset a statement to its initial state |+34
| `sqlite-finalize` | Free a statement |+35
+36
### Column access+37
+38
| Procedure | Purpose |+39
|-----------------------------|---------------------------------------------|+40
| `sqlite-column-count` | Number of columns in the current row |+41
| `sqlite-column-name` | Column name by 0-based index |+42
| `sqlite-column` | Column value by 0-based index |+43
+44
### Database info+45
+46
| Procedure | Purpose |+47
|-----------------------------|---------------------------------------------|+48
| `sqlite-last-insert-rowid` | rowid of the last insert |+49
| `sqlite-changes` | Rows changed by the last statement |+50
| `sqlite-errmsg` | Last error message |+51
+52
### High-level helpers+53
+54
| Procedure | Purpose |+55
|-----------------------------|---------------------------------------------|+56
| `sqlite-query` | Run query; return all rows as alists |+57
| `sqlite-query-row` | Run query; return first row or `#f` |+58
| `sqlite-run` | Run INSERT/UPDATE/DELETE with parameters |+59
+60
### Predicates+61
+62
| Procedure | Purpose |+63
|--------------------|-----------------------------------|+64
| `sqlite-db?` | SQLite database handle predicate |+65
| `sqlite-stmt?` | Prepared statement predicate |+66
+67
## System prerequisites+68
+69
None beyond a working C toolchain. The SQLite amalgamation+70
(`vendor/sqlite3.c` + `vendor/sqlite3.h`) is vendored and compiled+71
in-tree with these build flags:+72
+73
- `-DSQLITE_THREADSAFE=0`+74
- `-DSQLITE_OMIT_LOAD_EXTENSION`+75
- `-DSQLITE_ENABLE_FTS5`+76
+77
## Dependencies+78
+79
- sigil-stdlib+80
+81
## Build+82
+83
```sh+84
sigil deps install+85
sigil build+86
sigil test --report+87
```+88
+89
The first build compiles the SQLite amalgamation (one large+90
translation unit) plus `native/sqlite.c`. Subsequent builds hit the+91
cache.+92
+93
## Usage+94
+95
```scheme+96
(import (sigil sqlite))+97
+98
(call-with-database "app.db"+99
(lambda (db)+100
(sqlite-exec db "CREATE TABLE IF NOT EXISTS users+101
(id INTEGER PRIMARY KEY, name TEXT)")+102
(sqlite-run db "INSERT INTO users (name) VALUES (?)" "Alice")+103
(sqlite-query db "SELECT * FROM users")))+104
;; => (((id . 1) (name . "Alice")))+105
```+106
+107
## License+108
+109
BSD-3-Clause.+110
+111
Vendored SQLite (under `vendor/`) is public domain. See+112
`vendor/sqlite3.c` for the SQLite blessing.dev-redirects.sgladded
@@ -0,0 +1,6 @@
+1
;; Development redirects — point dependencies at local Sigil checkout+2
(redirects+3
repos: (list+4
(for-repo+5
url: "codeberg:sigil/sigil"+6
use: (from-path dir: "../sigil"))))manifest.scmadded
@@ -0,0 +1,7 @@
+1
;; sigil-sqlite Development Environment+2
;; Use with: guix shell -m manifest.scm+3
+4
(specifications->manifest+5
'("gcc-toolchain"+6
"make"+7
"pkg-config"))package.sglmodified
@@ -5,13 +5,14 @@
5
6
(package 7
name: "sigil-sqlite"+8
version: "0.13.1" 9
description: "SQLite database bindings for Sigil"−9
url: "https://codeberg.org/sigil/sigil"+10
url: "https://codeberg.org/sigil/sigil-sqlite" 11
license: "BSD-3-Clause" 12
authors: (list "David Wilson <[email protected]>") 13
14
dependencies: (list−14
(from-workspace name: "sigil-stdlib"))+15
(from-git url: "codeberg:sigil/sigil" package: "sigil-stdlib" version: "^0.13.1")) 16
17
;; Native library definition 18
libraries: (list@@ -43,13 +44,11 @@
44
;; Compile sqlite bindings 45
(compile-c-sources 46
sources: '("native/sqlite.c")−46
include-dirs: '("../sigil-lib/include"−47
"../sigil-lib/src"−48
"vendor")−49
flags: '("-std=c99"−50
"-Wall" "-Wextra"−51
"-Wno-unused-parameter"−52
"-D_GNU_SOURCE"))+47
include-dirs: '("vendor")+48
flags: (with-sigil-c-flags '("-std=c99"+49
"-Wall" "-Wextra"+50
"-Wno-unused-parameter"+51
"-D_GNU_SOURCE"))) 52
53
;; Create static library 54
(create-static-librarysigil.lockadded
@@ -0,0 +1,8 @@
+1
;; Auto-generated by sigil deps install. Do not edit.+2
(lock+3
(package name: "sigil-stdlib"+4
url: "codeberg:sigil/sigil"+5
ref: "^0.13.1"+6
sha: "1aea1cecd3487bf07d071da2c1e7eb3cf4bbdb21"+7
package-selector: "sigil-stdlib")+8
)test/main.cmodified
@@ -13,7 +13,7 @@ extern void sigil__init_sigil_sqlite_module(SigilVM *vm);
13
14
int main(int argc, char *argv[]) 15
{−16
const char *script_path = "test/test.sgl";+16
const char *script_path = "test/test-sqlite.sgl"; 17
18
if (argc >= 2) { 19
script_path = argv[1];test/test.sgl → test/test-sqlite.sglrenamed
No content change.