12 lines
294 B
Python

from sqlalchemy import text
from sqlalchemy.exc import SQLAlchemyError
from sqlalchemy.ext.asyncio import AsyncSession
async def database_available(db: AsyncSession) -> bool:
try:
await db.execute(text("SELECT 1"))
except SQLAlchemyError:
return False
return True