SCGR commited on
Commit
36535c6
·
1 Parent(s): 4eec04c

db url fix

Browse files
Files changed (1) hide show
  1. py_backend/app/database.py +4 -0
py_backend/app/database.py CHANGED
@@ -8,6 +8,10 @@ from .config import settings
8
 
9
  raw_db_url = settings.DATABASE_URL
10
 
 
 
 
 
11
  # Only add sslmode=require for remote connections, not localhost
12
  if "sslmode=" not in raw_db_url and "localhost" not in raw_db_url and "127.0.0.1" not in raw_db_url:
13
  raw_db_url = f"{raw_db_url}{'&' if '?' in raw_db_url else '?'}sslmode=require"
 
8
 
9
  raw_db_url = settings.DATABASE_URL
10
 
11
+ # Clean the URL if it starts with 'psql ' (common in some environments)
12
+ if raw_db_url.startswith("psql '") and raw_db_url.endswith("'"):
13
+ raw_db_url = raw_db_url[6:-1] # Remove "psql '" prefix and "'" suffix
14
+
15
  # Only add sslmode=require for remote connections, not localhost
16
  if "sslmode=" not in raw_db_url and "localhost" not in raw_db_url and "127.0.0.1" not in raw_db_url:
17
  raw_db_url = f"{raw_db_url}{'&' if '?' in raw_db_url else '?'}sslmode=require"