Skip to main content

What Is SQLite?

SQLite is a small, fast database engine that runs inside your application.

There is usually no server to install, no ports to open, and no admin user to configure. Your app links to SQLite like a normal library.

Core Concepts

Embedded, Serverless, File-Based

flowchart TD
A[Your App Process] --> B[SQLite library]
B --> C[SQL engine]
C --> D[Storage engine]
D --> E[(database.db file)]

What SQLite Gives You

FeatureWhat it means in practiceWhy you care
Transactions (ACID)Changes are all-or-nothingPrevents partial writes
Single-file databaseData lives in one portable fileEasy deployment and backup
Cross-platformSame file format everywhereGreat for apps shipped to users
Mature SQL engineSELECT queries are optimized and reliablePredictable performance

Code Examples

SQLite values have a runtime storage class. This is one reason SQLite feels "more flexible" than some databases.

-- typeof() shows the storage class of each value.
-- This is SQLite-specific and does not require any tables.
SELECT
typeof(123) AS t_integer,
typeof(123.0) AS t_real,
typeof('123') AS t_text,
typeof(NULL) AS t_null;
t_integert_realt_textt_null
integerrealtextnull

SQLite-Specific Nuances

SQLite Nuance

SQLite uses dynamic typing with type affinity.

  • A column's declared type influences how values are stored and compared
  • But the type system is not as strict as many client/server databases

Later, you'll see how constraints help you keep data clean even with SQLite's flexibility.

Common Pitfalls / Best Practices

Pitfall

Assuming SQLite automatically provides user accounts, roles, and permissions.

SQLite typically relies on file permissions plus application-level access control.

Best Practice

Treat the database file as important application data:

  • Put it in an appropriate app data directory
  • Back it up
  • Avoid editing it with non-database tools

Quick Challenge

Without running anything, predict the output of:

SELECT typeof(1 + 1) AS t;

View Solution

SQLite evaluates 1 + 1 as an integer.

SELECT typeof(1 + 1) AS t;
t
integer