Spaces:
Sleeping
Sleeping
Fix pgbouncer connection option error in config.py
Browse files- backend/config.py +12 -1
backend/config.py
CHANGED
|
@@ -8,7 +8,18 @@ class Config:
|
|
| 8 |
SECRET_KEY = os.environ.get('SECRET_KEY', 'personaflow-secret-key-change-in-production')
|
| 9 |
|
| 10 |
# Database
|
| 11 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 12 |
SQLALCHEMY_TRACK_MODIFICATIONS = False
|
| 13 |
|
| 14 |
# OpenRouter Settings
|
|
|
|
| 8 |
SECRET_KEY = os.environ.get('SECRET_KEY', 'personaflow-secret-key-change-in-production')
|
| 9 |
|
| 10 |
# Database
|
| 11 |
+
db_url = os.environ.get('DATABASE_URL', 'sqlite:///personaflow.db')
|
| 12 |
+
if db_url.startswith('postgres://'):
|
| 13 |
+
db_url = db_url.replace('postgres://', 'postgresql://', 1)
|
| 14 |
+
if 'pgbouncer=' in db_url:
|
| 15 |
+
import urllib.parse as urlparse
|
| 16 |
+
url_parts = list(urlparse.urlparse(db_url))
|
| 17 |
+
query = urlparse.parse_qs(url_parts[4])
|
| 18 |
+
query.pop('pgbouncer', None)
|
| 19 |
+
url_parts[4] = urlparse.urlencode(query, doseq=True)
|
| 20 |
+
db_url = urlparse.urlunparse(url_parts)
|
| 21 |
+
|
| 22 |
+
SQLALCHEMY_DATABASE_URI = db_url
|
| 23 |
SQLALCHEMY_TRACK_MODIFICATIONS = False
|
| 24 |
|
| 25 |
# OpenRouter Settings
|