SQLite vs Other Databases
SQLite is not "better" or "worse" than PostgreSQL or MySQL.
It is optimized for a different set of constraints: shipping with your app, local access, and low operational overhead.
Core Concepts
Embedded vs Client/Server
flowchart LR
subgraph Embedded[Embedded (SQLite)]
A1[App] --> B1[SQLite library]
B1 --> C1[(app.db)]
end
subgraph ClientServer[Client/Server (e.g., PostgreSQL/MySQL)]
A2[App] -->|network| B2[(DB server)]
end
Quick Comparison Table
| Dimension | SQLite | Client/Server DBs (general) |
|---|---|---|
| Deployment | Ship a library + a file | Run and manage a server |
| Typical access | Local filesystem | Network connections |
| Write concurrency | Many readers, one writer (typical) | Designed for many concurrent writers |
| Administration | Minimal | Backups, users/roles, upgrades, monitoring |
| Best fit | Local-first apps, embedded, single-node services | Central shared databases for many clients |
- Choose SQLite When
- Choose Server DB When
- You want the database to live with the application
- You need simple, reliable local storage
- You want minimal operational overhead
- Many app instances must write concurrently
- You need centralized access control and network-based clients
- You need operational features that come with a server (roles, replication, etc.)
Code Examples
Most basic SQL is portable. This query works in SQLite and many other databases.
-- A tiny, portable query.
SELECT 1 AS one;
| one |
|---|
| 1 |
SQLite-Specific Nuances
SQLite is optimized to be embedded and file-based.
That means performance and safety depend heavily on how your application uses the file (workload patterns, transactions, and concurrency).
Common Pitfalls / Best Practices
Picking SQLite for a workload that looks like a high-concurrency, multi-tenant server database.
If you expect many concurrent writers across multiple machines, evaluate a client/server database early.
Choose your database based on the workload, not the popularity.
Write down:
- expected data size
- read/write ratio
- concurrency needs
- deployment constraints
Quick Challenge
For each scenario, pick SQLite or client/server:
- A mobile app needs offline storage for user data
- A web app has 20 application servers and constant writes to shared tables
View Solution
- Mobile offline storage: SQLite
- Many servers with constant shared writes: typically client/server