from sqlalchemy import create_engine
import os
from dotenv import load_dotenv

# Ensure we are in the correct directory to load .env
load_dotenv()
db_url = os.getenv("DATABASE_URL")
print(f"Testing connection to: {db_url}")
try:
    if not db_url:
        print("DATABASE_URL not found in environment!")
    else:
        engine = create_engine(db_url)
        with engine.connect() as conn:
            print("Connection successful!")
except Exception as e:
    print(f"Connection failed: {e}")
