"""Backend detection — SQLITE (default) or POSTGRES based on DATABASE_URL.""" from __future__ import annotations import os from enum import Enum class Backend(Enum): SQLITE = "sqlite" POSTGRES = "postgres" def _detect() -> Backend: url = os.environ.get("DATABASE_URL", "") if url.startswith(("postgresql://", "postgres://", "postgresql+psycopg://")): return Backend.POSTGRES return Backend.SQLITE BACKEND: Backend = _detect()