SQLite Local Usage Guide
SQLite is a file-based embedded database that does not require a standalone service, commonly used as db.sqlite3 in local development with Rails/Django/Flask.
SQLite stores the database as a single file (e.g., db.sqlite3), eliminating the need to start a daemon like MySQL. The access path is a file path rather than localhost:port (unless accessed through an SQL proxy service).
Typical Local Scenarios
| Framework | File Location |
|---|---|
| Rails | db/development.sqlite3 |
| Django | db.sqlite3 (project root) |
| Laravel | database/database.sqlite |
| Node | Custom .db path |
Connection string examples: sqlite:///./db.sqlite3 or file:./app.db
Command Line
sqlite3 db.sqlite3
.tables
.schema users
SELECT * FROM users LIMIT 5;
.quitGraphical Management
- DB Browser for SQLite (cross-platform desktop)
- TablePlus, DBeaver
- phpLiteAdmin (Web, see our article on
phpliteadmin)
Comparison with MySQL/PostgreSQL
| Item | SQLite | PostgreSQL |
|---|---|---|
| Deployment | Single file | Service :5432 |
| Concurrent Write | Weak | Strong |
| Use Case | Local development, embedded, mobile | Production Web |
Python Example
import sqlite3
conn = sqlite3.connect('app.db')
conn.execute('CREATE TABLE IF NOT EXISTS users (id INTEGER PRIMARY KEY, name TEXT)')
conn.commit()
conn.close()Frequently Asked Questions
database is locked
Occurs when multiple processes write simultaneously; avoid multiple server instances writing to the same file during development.
With phpLiteAdmin
For web management of SQLite files, see the phpliteadmin article, requires Apache+PHP.
Conclusion
SQLite does not use localhost:port, and accesses the database through database files, making it the most convenient storage solution for local prototyping and single-user development.