diff --git a/worker/src/db.py b/worker/src/db.py index b73ed63..a6fffe4 100644 --- a/worker/src/db.py +++ b/worker/src/db.py @@ -7,6 +7,10 @@ logger = logging.getLogger(__name__) _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: global _pool if _pool is None: @@ -18,7 +22,7 @@ async def get_pool() -> asyncpg.Pool: database=os.getenv("POSTGRES_DB", "postgres"), min_size=2, max_size=10, - init="SET search_path TO willhaben_tracker" + init=_init_connection ) logger.info("Database pool initialized") return _pool