Spaces:
Running
Running
File size: 1,646 Bytes
0a96199 |
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 42 43 44 45 46 47 48 49 50 |
#!/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()
|