D Ф m i И i q ц e L Ф y e r commited on
Commit ·
47b3a88
1
Parent(s): 4016d03
Fix database connection to use SYSCRED_DATABASE_URL environment variable
Browse files- syscred/database.py +11 -5
syscred/database.py
CHANGED
|
@@ -166,11 +166,17 @@ class AnalysisResult(db.Model):
|
|
| 166 |
|
| 167 |
def init_db(app):
|
| 168 |
"""Initialize the database with the Flask app."""
|
| 169 |
-
#
|
| 170 |
-
|
| 171 |
-
|
| 172 |
-
|
| 173 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 174 |
|
| 175 |
app.config['SQLALCHEMY_DATABASE_URI'] = db_url
|
| 176 |
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
|
|
|
|
| 166 |
|
| 167 |
def init_db(app):
|
| 168 |
"""Initialize the database with the Flask app."""
|
| 169 |
+
# Check for SYSCRED_DATABASE_URL environment variable (UQAM PostgreSQL)
|
| 170 |
+
db_url = os.environ.get('SYSCRED_DATABASE_URL')
|
| 171 |
+
|
| 172 |
+
if db_url:
|
| 173 |
+
print(f"[SysCRED-DB] Using PostgreSQL database: {db_url}")
|
| 174 |
+
else:
|
| 175 |
+
# Fallback to SQLite - Supabase operations use REST API separately
|
| 176 |
+
import tempfile
|
| 177 |
+
db_path = os.path.join(tempfile.gettempdir(), 'syscred.db')
|
| 178 |
+
db_url = f'sqlite:///{db_path}'
|
| 179 |
+
print(f"[SysCRED-DB] Using SQLite (Supabase uses REST API): {db_path}")
|
| 180 |
|
| 181 |
app.config['SQLALCHEMY_DATABASE_URI'] = db_url
|
| 182 |
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
|