fix: use async callable for asyncpg pool init instead of string
This commit is contained in:
+5
-1
@@ -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
|
||||||
|
|||||||
Reference in New Issue
Block a user