Spaces:
Running
Running
#!/usr/bin/env python3 | |
""" | |
Simple database connection test | |
""" | |
import os | |
from sqlalchemy import create_engine, text | |
def test_connection(): | |
"""Test database connection""" | |
# You need to replace YOUR_ACTUAL_PASSWORD with your real Supabase password | |
DATABASE_URL = "postgresql://postgres:YOUR_ACTUAL_PASSWORD@db.ckrqyjfdifjbsuuofegd.supabase.co:5432/postgres" | |
print("Testing database connection...") | |
print(f"Host: db.ckrqyjfdifjbsuuofegd.supabase.co") | |
print(f"Port: 5432") | |
print(f"Database: postgres") | |
print(f"User: postgres") | |
print() | |
try: | |
# Create engine | |
engine = create_engine(DATABASE_URL, pool_pre_ping=True) | |
# Test connection | |
with engine.connect() as conn: | |
print("β Connection successful!") | |
# Test a simple query | |
result = conn.execute(text("SELECT version()")) | |
version = result.fetchone()[0] | |
print(f"β Database version: {version}") | |
# Test if we can create a table | |
print("β Database is accessible and ready for use!") | |
except Exception as e: | |
print(f"β Connection failed: {e}") | |
print() | |
print("To fix this:") | |
print("1. Update the password in this script (replace YOUR_ACTUAL_PASSWORD)") | |
print("2. Or set the environment variable:") | |
print(" export DATABASE_URL='postgresql://postgres:YOUR_PASSWORD@db.ckrqyjfdifjbsuuofegd.supabase.co:5432/postgres'") | |
print("3. Make sure your IP is whitelisted in Supabase") | |
if __name__ == "__main__": | |
test_connection() | |