Files
ems/backend/app/deps.py
Dusan Vojacek 8b4af663d8 Initial commit
Made-with: Cursor
2026-03-20 13:27:44 +01:00

20 lines
432 B
Python

"""Sdílené FastAPI závislosti (DB pool)."""
from __future__ import annotations
import asyncpg
from fastapi import HTTPException
_pg_pool: asyncpg.Pool | None = None
def set_pg_pool(pool: asyncpg.Pool | None) -> None:
global _pg_pool
_pg_pool = pool
async def get_pg_pool() -> asyncpg.Pool:
if _pg_pool is None:
raise HTTPException(status_code=503, detail="Database pool not ready")
return _pg_pool