fix: use async callable for asyncpg pool init instead of string

This commit is contained in:
2026-07-04 11:23:15 +02:00
parent 753174b946
commit fa551556e6
+5 -1
View File
@@ -7,6 +7,10 @@ logger = logging.getLogger(__name__)
_pool: asyncpg.Pool | None = None _pool: asyncpg.Pool | None = None
async def _init_connection(conn: asyncpg.Connection) -> None:
await conn.execute("SET search_path TO willhaben_tracker")
async def get_pool() -> asyncpg.Pool: async def get_pool() -> asyncpg.Pool:
global _pool global _pool
if _pool is None: if _pool is None:
@@ -18,7 +22,7 @@ async def get_pool() -> asyncpg.Pool:
database=os.getenv("POSTGRES_DB", "postgres"), database=os.getenv("POSTGRES_DB", "postgres"),
min_size=2, min_size=2,
max_size=10, max_size=10,
init="SET search_path TO willhaben_tracker" init=_init_connection
) )
logger.info("Database pool initialized") logger.info("Database pool initialized")
return _pool return _pool