Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ passlib[bcrypt]==1.7.4
bcrypt==4.3.0
python-multipart==0.0.21
asyncpg==0.31.0
psycopg2-binary==2.9.11
psycopg[binary]==3.2.4
requests==2.32.5
python-dotenv==1.2.1
alembic==1.17.2
Expand Down
10 changes: 5 additions & 5 deletions scripts/wait_for_database.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"""

import sys
import psycopg2
import psycopg
import os
from urllib.parse import urlparse
import time
Expand All @@ -22,16 +22,16 @@ def create_database_if_not_exists():

try:
# First try to connect to the target database
psycopg2.connect(database_url)
psycopg.connect(database_url)
print("Database connection successful")
return True
except psycopg2.OperationalError as e:
except psycopg.OperationalError as e:
# If database doesn't exist, try to create it
if "does not exist" in str(e) or "database" in str(e).lower():
print("Database does not exist, attempting to create it...")
try:
# Connect to postgres database to create the target database
conn = psycopg2.connect(base_url)
conn = psycopg.connect(base_url)
conn.autocommit = True
cursor = conn.cursor()

Expand All @@ -46,7 +46,7 @@ def create_database_if_not_exists():
print(f"Database '{db_name}' created successfully")

# Try connecting again to verify
psycopg2.connect(database_url)
psycopg.connect(database_url)
print("Database connection verified after creation")
return True
except Exception as create_error:
Expand Down
Loading