ALM-2 / backend /tests /test_db_connection.py
ACA050's picture
Upload 520 files
2ed8996 verified
Raw
History Blame Contribute Delete
1.02 kB
"""
Simple Database Connection Test for AegisLM
"""
import asyncio
import sys
import os
# Add to backend directory
sys.path.append(os.path.dirname(os.path.abspath(__file__)))
async def test_db_connection():
"""Test database connection without SSL requirements."""
try:
from core.database import AsyncSessionLocal
print("🔍 Testing database connection...")
async with AsyncSessionLocal() as db:
from sqlalchemy import text
result = await db.execute(text("SELECT 1 as test"))
print("✅ Database connection successful!")
return True
except Exception as e:
print(f"❌ Database connection failed: {str(e)}")
print("💡 This might be because:")
print(" 1. PostgreSQL is not running")
print(" 2. Database doesn't exist")
print(" 3. Connection details are incorrect")
return False
if __name__ == "__main__":
asyncio.run(test_db_connection())