Skip to main content

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

RequirementSQLite fit?Notes
Local-first/offline appYesCommon mobile/desktop pattern
Single-node serviceOftenGreat if writes are not highly contended
Many concurrent writers across hostsNo (usually)Prefer client/server
Built-in users/rolesNoSQLite typically uses file permissions
Minimal ops overheadYesZero-config by design
  • Mobile and desktop apps
  • Embedded devices and edge systems
  • Local caches and queues
  • Test databases for development

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:

  1. A single-user desktop finance tracker
  2. A chat service with thousands of writes per second across many servers
View Solution
  1. Desktop finance tracker: SQLite
  2. Multi-server high-write chat service: typically not SQLite (client/server is a better fit)