Data & IdentityM6
SQLite, Parameterized Queries, Transactions & Migrations
SQL-injection-safe sqlite3_bind_* binding, atomic idempotent db_migrate, and WAL online backups.
6 min readUpdated: v0.8.0-rc Reference
SQLite Adapter Guarantees
db_openenablesPRAGMA foreign_keys = ONand WAL mode on file databases and registers the handle for automatic cleanup on abort.- All parameters pass through a strict RFC 8259 JSON array bound with
sqlite3_bind_*(never string concatenation). db_migrateexecutes schema changes atomically and tracks applied versions in_hadid_migrations.db_backupuses the SQLite Online Backup API (sqlite3_backup_*) for live snapshots.
hadidLocal CLI: hadid run
match (db_open("app.sqlite")) { Err(e) => { assert(false, e); } Ok(db) => { db_migrate(db, "0001_notes", "CREATE TABLE notes(id INTEGER PRIMARY KEY, body TEXT NOT NULL);"); db_exec(db, "INSERT INTO notes(body) VALUES(?1);", "[\"Safe parameterized value\"]"); db_backup(db, "app-backup.sqlite"); db_close(db); }}