import asyncio from app.database import AsyncSessionLocal from sqlalchemy import text async def test(): try: async with AsyncSessionLocal() as session: result = await session.execute(text('SELECT 1')) print("数据库连接成功:", result.scalar()) except Exception as e: print("数据库连接失败:", e) import traceback traceback.print_exc() asyncio.run(test())