D Ф m i И i q ц e L Ф y e r commited on
Commit
4a8c1eb
·
1 Parent(s): 3835e0c

Fix: Use direct DATABASE_URL first for HF compatibility

Browse files
Files changed (1) hide show
  1. syscred/database.py +3 -2
syscred/database.py CHANGED
@@ -38,8 +38,9 @@ class AnalysisResult(db.Model):
38
 
39
  def init_db(app):
40
  """Initialize the database with the Flask app."""
41
- # Prefer SYSCRED_DATABASE_URL (pooler), then DATABASE_URL (direct)
42
- db_url = os.environ.get('SYSCRED_DATABASE_URL') or os.environ.get('DATABASE_URL')
 
43
  if db_url and db_url.startswith("postgres://"):
44
  db_url = db_url.replace("postgres://", "postgresql://", 1)
45
 
 
38
 
39
  def init_db(app):
40
  """Initialize the database with the Flask app."""
41
+ # Prefer DATABASE_URL (direct connection), then SYSCRED_DATABASE_URL (pooler)
42
+ # HF Spaces often can't resolve the pooler hostname
43
+ db_url = os.environ.get('DATABASE_URL') or os.environ.get('SYSCRED_DATABASE_URL')
44
  if db_url and db_url.startswith("postgres://"):
45
  db_url = db_url.replace("postgres://", "postgresql://", 1)
46