Latticework

Command Palette

Search for a command to run...

SQLite

File-Based Database Basics

16 min

Explanation

SQLite isn't a client-server database like PostgreSQL or MySQL — there's no separate database server to connect to at all. It's a library linked directly into your application, and an entire database (tables, indexes, everything) lives in one ordinary file on disk. This makes it an extremely common choice for local app storage, mobile apps, embedded systems, and anywhere a full server would be unnecessary overhead — the exact same SQL you already know from the SQL course still applies.

CREATE TABLE settings (key TEXT, value TEXT, updated_at INTEGER);
INSERT INTO settings (key, value, updated_at) VALUES
  ('theme', 'dark', 100),
  ('language', 'en', 105),
  ('notifications', 'on', 98);
Try it

This whole database -- schema, data, everything -- is just ONE FILE, which is exactly why SQLite is the default storage engine baked into iOS and Android, and why tools like this in-browser sandbox itself can run a real embedded SQLite (via the sql.js WASM build) with zero server setup at all.

Loading editor…
Exercise

The `settings` table stores an app's local configuration as key/value pairs, each with an `updated_at` timestamp. Write a query that returns the `key` and `value` of every setting updated after timestamp `99`, ordered by `key`.

Quiz

What makes SQLite fundamentally different from a database like PostgreSQL or MySQL, architecturally?

Checkpoint

You understand SQLite's embedded, file-based architecture, and can query it with the same SQL you already know.