When to Use SQLite
SQLite is an excellent default for many applications, but not for every workload.
This page gives you a simple way to decide.
Core Concepts
A Quick Decision Flow
flowchart TD
A[Do you need a database?] --> B{Will many machines<br/>write concurrently?}
B -->|Yes| C[Consider a client/server DB]
B -->|No| D{Is local, simple<br/>deployment important?}
D -->|Yes| E[SQLite is a strong fit]
D -->|No| F{Do you need<br/>centralized access control?}
F -->|Yes| C
F -->|No| E
Checklist: Fit vs Not Fit
| Requirement | SQLite fit? | Notes |
|---|---|---|
| Local-first/offline app | Yes | Common mobile/desktop pattern |
| Single-node service | Often | Great if writes are not highly contended |
| Many concurrent writers across hosts | No (usually) | Prefer client/server |
| Built-in users/roles | No | SQLite typically uses file permissions |
| Minimal ops overhead | Yes | Zero-config by design |
- Great Fits
- Maybe
- Avoid
- Mobile and desktop apps
- Embedded devices and edge systems
- Local caches and queues
- Test databases for development
- Small shared services with moderate traffic
- Analytics on a single machine
- Applications with occasional bursts of writes
- Heavy write contention with many writers
- Multi-tenant systems that need fine-grained access control
- Architectures that require replication across machines
Code Examples
One reason SQLite is easy to adopt is that the database is a file.
# SQLite databases are files. This is a conceptual example showing portability.
# (There is usually no terminal output when a copy succeeds.)
cp app.db app.db.bak
| outcome |
|---|
app.db.bak is created (no output on success) |
SQLite-Specific Nuances
SQLite Nuance
Because SQLite is file-based, backups can be simple, but they must be done safely.
Later, you'll learn SQLite-specific ways to back up while the database is in use (online backup) in Backup a database.
Common Pitfalls / Best Practices
Pitfall
Putting a SQLite database on an unreliable network filesystem.
SQLite relies on filesystem locking semantics for correctness; not all network shares behave well.
Best Practice
If you are unsure, prototype with SQLite and measure.
SQLite is a great "default" until your workload proves you need a dedicated server database.
Quick Challenge
Choose the best fit for SQLite:
- A single-user desktop finance tracker
- A chat service with thousands of writes per second across many servers
View Solution
- Desktop finance tracker: SQLite
- Multi-server high-write chat service: typically not SQLite (client/server is a better fit)