Multiple databases#

You can define more than one DB:

DATABASES = {
    "default": {...},
    "analytics": {...},
}
Django will:
  • Open separate connections

  • Keep them alive independently

  • Let you choose which DB to read/write from

Django does NOT automatically split data between them.

You must tell Django what goes where.


Production-grade example#

DATABASES = {
    "default": {
        "ENGINE": "django.db.backends.postgresql",
        "NAME": "app_db",
        ...
    },
    "analytics": {
        "ENGINE": "django.db.backends.postgresql",
        "NAME": "analytics_db",
        ...
    },
}
  • default → live application

  • analytics → heavy reporting (safe, no locks)