fix: use await engine.connect() instead of async with
SQLAlchemy 2.0 async engine.connect() doesn't support context manager. Use explicit connect/close instead.
This commit is contained in:
@@ -44,8 +44,11 @@ async def init_database(
|
||||
try:
|
||||
# Test basic connectivity
|
||||
from sqlalchemy import text
|
||||
async with engine.connect() as conn:
|
||||
conn = await engine.connect()
|
||||
try:
|
||||
await conn.execute(text("SELECT 1"))
|
||||
finally:
|
||||
await conn.close()
|
||||
|
||||
logger.info("Database connection established.")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user