Files
sqlite3/README.md
2023-02-28 16:02:13 +00:00

3.2 KiB

Go bindings to SQLite using Wazero

Go Reference Go Report Go Coverage

⚠️ Work in Progress ⚠️

Go module github.com/ncruces/go-sqlite3 wraps a WASM build of SQLite, and uses wazero to provide cgo-free SQLite bindings.

Caveats

Because WASM does not support shared memory, WAL support is limited.

To work around this limitation, SQLite is compiled with SQLITE_DEFAULT_LOCKING_MODE=1, making EXCLUSIVE the default locking mode. For non-WAL databases, NORMAL locking mode can be activated with PRAGMA locking_mode=NORMAL.

Because connection pooling is incompatible with EXCLUSIVE locking mode, the database/sql driver defaults to NORMAL locking mode, and WAL databases are not supported.

Roadmap

  • build SQLite using zig cc --target=wasm32-wasi
  • :memory: databases
  • port test_demovfs.c to Go
    • branch wasi uses test_demovfs.c directly
  • design a nice API, enough for simple use cases
  • provide a simple database/sql driver
  • file locking, compatible with SQLite on macOS/Linux/Windows
  • advanced SQLite features
    • nested transactions
    • incremental BLOB I/O
    • online backup
    • snapshots
    • session extension
    • resumable bulk update
    • shared cache mode
  • custom SQL functions
  • custom VFSes

Alternatives