This commit is contained in:
2026-06-10 02:04:37 -06:00
parent 1ba3d8dea4
commit 31cdce03a0
131 changed files with 15922 additions and 106 deletions
+33
View File
@@ -0,0 +1,33 @@
from __future__ import annotations
import asyncpg
from app.config import settings
pool: asyncpg.Pool | None = None
async def init_db() -> None:
global pool
pool = await asyncpg.create_pool(
host=settings.DB_HOST,
port=settings.DB_PORT,
user=settings.DB_USER,
password=settings.DB_PASSWORD,
database=settings.DB_NAME,
min_size=2,
max_size=10,
)
async def close_db() -> None:
global pool
if pool:
await pool.close()
pool = None
async def get_pool() -> asyncpg.Pool:
if pool is None:
raise RuntimeError("Database pool not initialized. Call init_db() first.")
return pool