Skip to content

SQLite checklist

Copy this list into a pull request, design review or project kickoff and tick what applies. Rules are grouped by level and sorted by score (criteria). Each links to the file that explains it and cites its sources. Automatable names tools that can check the rule in CI (see the file's "How to enforce" section).

Also apply the general checklist.

This file is generated by python3 scripts/rank.py fix from the guidelines. Don't edit it by hand.

  • SQLITE-6 (9) Bind values with SQLite's placeholders, ? or :name, through the driver's parameter API, such as the second argument of Python's execute(). (specific/sqlite) Automatable: CodeQL, SQL query built from user-controlled sources, Ruff hardcoded-sql-expression (S608).
  • SQLITE-1 (8) Use SQLite where the data is on the same machine as the code that queries it and writers can take turns; choose a client/server database, such as PostgreSQL, when the data is on another machine, many processes must write at the same instant, or the data is heading for terabytes. (specific/sqlite)
  • SQLITE-2 (8) Never share a database between processes or machines through a network file system, such as NFS or SMB. (specific/sqlite)
  • SQLITE-3 (8) Configure every connection in one place as soon as it opens: PRAGMA foreign_keys=ON, a busy timeout, and PRAGMA trusted_schema=OFF. (specific/sqlite) Automatable: PRAGMA foreign_key_check.
  • SQLITE-11 (8) Copy a live database only with the online backup API, VACUUM INTO or sqlite3_rsync, never copy the database file while a connection may be writing to it, and never delete, rename or separate it from its -wal or -journal file. (specific/sqlite)
  • SQLITE-4 (7) Use WAL mode (PRAGMA journal_mode=WAL) for databases that are read while they are written, set PRAGMA synchronous=NORMAL when each connection opens, and never set synchronous=OFF for data you need to keep. (specific/sqlite)
  • SQLITE-5 (7) Send all writes through one connection or a serial queue, start transactions that will write with BEGIN IMMEDIATE, and keep write transactions short. (specific/sqlite)
  • SQLITE-7 (7) Record the schema version in PRAGMA user_version, and when the app opens a database, apply the missing migrations in order, each in a transaction. For changes that ALTER TABLE can't make, follow SQLite's 12-step procedure for rebuilding a table and finish with PRAGMA foreign_key_check. (specific/sqlite) Automatable: PRAGMA foreign_key_check.
  • SQLITE-8 (6) Create new tables as STRICT tables once every SQLite version that opens the file is 3.37.0 or later. (specific/sqlite)
  • SQLITE-9 (6) Group related writes into one explicit transaction instead of letting each statement commit on its own. (specific/sqlite)
  • SQLITE-12 (6) Check backups and saves with PRAGMA integrity_check, or the faster quick_check, before you rely on them, and keep the previous good copy until the new one passes. (specific/sqlite)
  • SQLITE-13 (6) Treat a database file that someone else could have written, such as a shared save, a mod or a downloaded file, as untrusted input (SEC-10): keep trusted_schema off, and in security-sensitive apps run PRAGMA quick_check before any other statement, reject files that fail, and set PRAGMA cell_size_check=ON and PRAGMA mmap_size=0. (specific/sqlite)

Conditional (1–5)

  • SQLITE-10 (5) Index the columns that frequent queries filter, sort or join on, including the child columns of foreign keys, check plans with EXPLAIN QUERY PLAN, and run PRAGMA optimize as SQLite recommends: before closing short-lived connections, periodically on long-lived ones, and after schema changes. (specific/sqlite)
  • SQLITE-14 (5) If the app runs SQL written by users or mods, turn on SQLITE_DBCONFIG_DEFENSIVE, lower the limits with sqlite3_limit(), and restrict what statements may do with an authorizer callback. (specific/sqlite)