13.2 · SQLite fundamentals: transactions, WAL, constraints, indexes and migrations

SQLite is the engine under Core Data, SwiftData and most third-party stores. Understanding it directly tells you what those frameworks can and cannot do.

Mental model. SQLite is a file with transactions. Every guarantee you rely on, atomic commits, integrity, ordering, comes from using transactions and constraints deliberately.

The engine

Transactions, journal modes, constraints and pragmas.

  1. How do SQLite transactions, journal modes (WAL) and constraints work, and which defaults surprise people? 13.2.1 · L3
    SQLite stores a whole database in one file and gives ACID transactions: a group of statements between BEGIN and COMMIT either all take effect or, after…

Using it well

Binding parameters, indexes and schema migrations.

  1. How do you use SQLite safely and quickly: bound parameters, indexes, and schema migrations? 13.2.2 · L5
    Bind parameters, never concatenate. Build statements with ? placeholders (sqlite3_prepare_v2, then sqlite3_bind_text, sqlite3_step, sqlite3_finalize), so…

More in Persistence & data