19 lines
425 B
Python
19 lines
425 B
Python
import psycopg2
|
|
import os
|
|
from dotenv import load_dotenv
|
|
|
|
load_dotenv()
|
|
|
|
def test_db():
|
|
url = os.getenv("DATABASE_URL")
|
|
print(f"Testing connection to: {url.split('@')[-1]}")
|
|
try:
|
|
conn = psycopg2.connect(url)
|
|
print("Raw psycopg2 connection successful!")
|
|
conn.close()
|
|
except Exception as e:
|
|
print(f"Raw psycopg2 connection failed: {e}")
|
|
|
|
if __name__ == "__main__":
|
|
test_db()
|