Skip to content
IT glossary
DatabasesUpdated December 3, 2026

SQLite

An embedded relational database engine that runs inside an application instead of on a separate server. It typically stores data in a local file and lets the application query it with SQL.

What SQLite is

When an app uses PostgreSQL, it sends SQL statements to a separate database server. With SQLite, the app calls a library that runs in its own process. That library opens the database file and executes the statements. There is no database service to start, but the app still gets tables, joins, indexes, constraints, and transactions.

What happens when you write

The main database file holds the schema, table data, and indexes. SQLite uses either a rollback journal or a write-ahead log (WAL) to make transactions atomic. In WAL mode, a commit can be recorded in the log before the changes are copied back into the main database file. That is why copying just the main file while the app is running is not a reliable backup. For a live database, use a tool that takes a consistent snapshot, such as the sqlite3 shell's .backup command.

Multiple connections can open the same database, but only one can hold a write transaction at a time. WAL lets readers continue while a writer is active; it does not let two writers proceed together. If several parts of an application write frequently, keep write transactions short. For instance, avoid waiting on a network request while holding one open.

Example: a local task list

Open sqlite3 tasks.db and run:

CREATE TABLE tasks (
    id INTEGER PRIMARY KEY,
    title TEXT NOT NULL,
    done INTEGER NOT NULL DEFAULT 0 CHECK (done IN (0, 1))
);
INSERT INTO tasks (title) VALUES ('Review interview notes');
SELECT id, title FROM tasks WHERE done = 0;

SQLite assigns the ID because the insert leaves it out. The query returns the unfinished task, and the row is still there when you reopen tasks.db.

Where it fits and what to watch for

SQLite is a natural fit for an offline mobile app, a desktop tool, or a web service whose writes rarely overlap. It is less suitable when multiple application instances on different machines need to write frequently to the same database. In that case, a client-server database is usually a better fit than trying to share a SQLite file over the network.

SQL dialects also differ. In an ordinary SQLite table, declaring a column INTEGER does not prevent it from storing text that cannot be converted to a number. Use a STRICT table when you need stronger type enforcement. If your schema relies on foreign keys, explicitly run PRAGMA foreign_keys = ON on each new connection before starting a transaction rather than assuming enforcement is enabled.

How it comes up in interviews

If asked to choose between SQLite and PostgreSQL, start with how the application is deployed and who writes the data. A large local database with mostly reads may be a good fit for SQLite, while a much smaller database with frequent concurrent writes may not be. Be ready to explain what WAL changes: readers and a writer can overlap, but writers still take turns.