-
Notifications
You must be signed in to change notification settings - Fork 1
Choosing a Database Engine
All three common options — SQLite, PostgreSQL, MySQL — are free. The database software itself is free in every case; cost only appears with cloud managed databases (e.g. AWS RDS), which is hosting cost, not a license fee. Postgres also has free hosting tiers (Supabase, Neon), so deploying can stay at $0.
| SQLite | PostgreSQL | MySQL | |
|---|---|---|---|
| License | Public domain | Open source (permissive) | GPL (Community); MariaDB is a fully-free fork |
| Setup | None (single file) | Server install | Server install |
| Concurrent writes | Weak (one at a time) | Strong | Strong |
| Django fit | Default | Best (de facto standard) | Fine |
| Deployment | Poor* | Excellent | Good |
| Best for | Local dev / learning | Production | (Postgres covers it) |
*On many hosting platforms the filesystem resets on redeploy, which can wipe the SQLite file entirely — so it's unsuitable for production.
Start on SQLite, switch to PostgreSQL for deployment.
- During development → SQLite. Zero setup; Django uses it by default.
- For deployment → PostgreSQL. Best Django fit, and it handles the daily batch and concurrent users without issue.
-
MySQL → not bad, but in the Django ecosystem Postgres is the standard, so there's little reason to pick it. Postgres also aligns better with the ORM (e.g.
JSONField, constraints).
Django makes swapping engines easy — only the DATABASES block in settings.py changes:
# Development (SQLite)
DATABASES = {
"default": {
"ENGINE": "django.db.backends.sqlite3",
"NAME": BASE_DIR / "db.sqlite3",
}
}
# Production (PostgreSQL) — requires: pip install psycopg2-binary
DATABASES = {
"default": {
"ENGINE": "django.db.backends.postgresql",
"NAME": os.environ["DB_NAME"],
"USER": os.environ["DB_USER"],
"PASSWORD": os.environ["DB_PASSWORD"],
"HOST": os.environ["DB_HOST"],
"PORT": "5432",
}
}Caveat: developing on SQLite but deploying on Postgres can surface subtle differences (e.g. case sensitivity). If that matters, run Postgres locally too (usually via Docker) to match dev and production. For learning, SQLite is the lighter way to start.