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.
- How do SQLite transactions, journal modes (WAL) and constraints work, and which defaults surprise people?
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.
- How do you use SQLite safely and quickly: bound parameters, indexes, and schema migrations?
Bind parameters, never concatenate. Build statements with ? placeholders (sqlite3_prepare_v2, then sqlite3_bind_text, sqlite3_step, sqlite3_finalize), so…
More in Persistence & data
- 13.1 · Where data belongs, and the Keychain
- 13.3 · The Core Data stack, contexts and faults, concurrency, and migrations
- 13.4 · SwiftData: models, contexts, predicates, actors and schema evolution
- 13.5 · The repository pattern and cache design
- 13.6 · Crashes mid-write, integrity, backups and data protection
- 13.7 · Syncing data across devices: conflicts, tombstones and CloudKit
- 13.8 · UserDefaults surprises and FileManager essentials
- 13.9 · Reading query plans, typing and NULL, WAL locking, savepoints and full-text search
- 13.10 · Merge conflicts, faults and batch requests, delete rules, and the SwiftData context
- 13.11 · Keychain status codes, detecting corruption, an LRU cache and library trade-offs