Home / Market / sqlite development

sqlite development

Design, debug, and migrate production SQLite databases. Configure WAL concurrency, enforce foreign keys and STRICT tables, sync FTS5 indexes, and rebuild schemas safely.

skill★ 507520 dlgithubCC-BY-4.0 content; MIT code; upstream exceptions applyInstall in CosmosUpstream Source

Documentation & Preview

--- name: sqlite-development description: "Design, debug, and migrate production SQLite databases. Configure WAL concurrency, enforce foreign keys and STRICT tables, sync FTS5 indexes, and rebuild schemas safely." category: database risk: critical source: self source_type: self date_added: "2026-11-30" author: ShianMike tags: [sqlite, sql, wal, fts5, migrations]

---

SQLite Development

When to Use

Prerequisites

Identify the SQLite library version (sqlite3.sqlite_version or SELECT sqlite_version()), driver/binding, concurrency pattern (single process vs multi-process, read/write ratio), and storage medium (local filesystem vs network mount). Inspect existing connection setup code, pragma defaults, and migration scripts. Avoid placing active WAL-mode SQLite databases on network filesystems where shared-memory locking does not work reliably.

Configure every connection intentionally

  1. Enable PRAGMA foreign_keys = ON on every new connection. SQLite defaults this setting to OFF per connection even when tables declare REFERENCES constraints. Run PRAGMA foreign_key_check after bulk loads or legacy repairs.
  2. Enable PRAGMA journal_mode = WAL and set a per-connection PRAGMA busy_timeout that fits the workload latency budget. With WAL and PRAGMA synchronous = NORMAL, an OS crash or power failure can roll back recently committed transactions. Use FULL when those commits must survive.
  3. Use BEGIN IMMEDIATE for transactions that will write. A default BEGIN DEFERRED transaction that reads first and upgrades to a write while another writer holds the lock fails immediately with SQLITE_BUSY without waiting for busy_timeout.
  4. Keep write transactions short and keep long read transactions from starving WAL checkpoints. Monitor WAL file growth and run explicit PRAGMA wal_checkpoint(TRUNCATE) during maintenance windows when needed.

Enforce types, indexes, and FTS5 sync

Run table-rebuild migrations safely

Example

> An application using SQLite silently stored orphan rows, accepted string prices in an integer column, and hit SQLITE_BUSY under concurrent writes.

Run the worked WAL concurrency and integrity test to reproduce each failure mode and verify per-connection foreign_keys, STRICT tables, and BEGIN IMMEDIATE serialization under WAL mode.

Limitations

Safety and Side Effects

Test schema rebuilds, checkpoints, and VACUUM on a copy of the database first. Use VACUUM INTO or the online backup API for a consistent live copy. For a raw file copy, close every connection and keep writers stopped until the copy is complete. Keep production paths and user records out of examples and logs.

Related Skills and Documentation