File size: 931 Bytes
363cda9 3370983 363cda9 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
"""
Test database session and query execution.
Run standalone:
>>> POSTGRES_HOST=localhost POSTGRES_PORT=5433 python scripts/db/test_session.py
"""
from sqlalchemy import text
# Ensure project root is in path
import scripts.db # noqa: F401
from src.backend.database.candidates.client import SessionLocal
def test_session_query() -> bool:
"""
Test session creation and basic query execution.
Returns:
True if session works, False otherwise.
"""
print("--- Testing Session Query ---")
session = SessionLocal()
try:
result = session.execute(text("SELECT now()"))
print(f"✅ Session execute successful: {result.fetchone()[0]}")
return True
except Exception as e:
print("\n❌ Session Query FAILED")
print(f"Error: {e}")
return False
finally:
session.close()
if __name__ == "__main__":
test_session_query()
|