SQLite

Zero setup. Full SQL. Single file.

What is it?

SQLite is a full relational database stored in a single .db file on disk — no server process, no configuration, no installation beyond the library itself. Your app reads and writes the file directly. It supports SQL fully, enforces types and constraints, and handles transactions. Despite being a single file, it's remarkably capable and is probably the most widely deployed database in the world — every iOS and Android app, every Firefox browser, and most desktop applications use it internally.


When to use it

SQLite is the ideal starting point when you want to learn SQL and database-backed development without any setup overhead. It's also the right choice for small web projects, desktop apps, and anything with one writer at a time. As your project grows to handle significant concurrent traffic — many users writing simultaneously — a server-based database like PostgreSQL or MySQL is the upgrade path.


Core concepts
  • The database is a filemyapp.db lives in your project folder and moves with it. Back it up like any file; delete it and the data is gone.
  • Serverless — there's no server to start, no ports to open. The library links directly into your app.
  • Standard SQL — nearly everything you learn in SQLite transfers to MySQL or PostgreSQL. Create tables, insert rows, join, query — the syntax is the same.
  • Type affinity — SQLite is more flexible about column types than other databases. This is handy while learning but worth being aware of.
  • Built into Python — Python ships with sqlite3 in the standard library, no install needed. Most other languages have first-class SQLite drivers.

A taste of the code
import sqlite3

conn = sqlite3.connect("notes.db")
cur = conn.cursor()

cur.execute("""
  CREATE TABLE IF NOT EXISTS notes (
    id      INTEGER PRIMARY KEY AUTOINCREMENT,
    title   TEXT NOT NULL,
    body    TEXT
  )
""")

cur.execute("INSERT INTO notes (title, body) VALUES (?, ?)",
            ("First note", "SQLite is easy."))
conn.commit()

for row in cur.execute("SELECT id, title FROM notes"):
    print(row)

That's a working database in pure Python. No server. No config. The file notes.db appears in the same folder when you run it.


Your first steps
  1. Learn the SQL fundamentals — they're identical in SQLite.
  2. If you're using Python, open the Python shell and import sqlite3 — it's already there. Create a connection, create a table, insert a row, and select it back.
  3. Install the SQLite Viewer extension for VS Code to browse your .db file visually while you develop.
  4. Build a small Flask app backed by SQLite — a todo list or notes app. Python, Flask, and SQLite together need zero external services.
  5. When you're ready to level up, the skills transfer directly to PostgreSQL — swap the connection string and you're mostly there.

← Back to Stack Picker All primers