lanna_lalala;- commited on
Commit ·
66cec0d
1
Parent(s): fa7a3bc
init frontend
Browse files- utils/db.py +12 -0
utils/db.py
CHANGED
|
@@ -7,6 +7,18 @@ from mysql.connector import Error
|
|
| 7 |
from contextlib import contextmanager
|
| 8 |
from datetime import date, timedelta
|
| 9 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
# password hashing
|
| 11 |
import bcrypt
|
| 12 |
|
|
|
|
| 7 |
from contextlib import contextmanager
|
| 8 |
from datetime import date, timedelta
|
| 9 |
|
| 10 |
+
|
| 11 |
+
DISABLE_DB = os.getenv("DISABLE_DB", "1") == "1"
|
| 12 |
+
|
| 13 |
+
try:
|
| 14 |
+
if DISABLE_DB:
|
| 15 |
+
raise ImportError("DB disabled in frontend Space")
|
| 16 |
+
import mysql.connector # provided by mysql-connector-python
|
| 17 |
+
except Exception:
|
| 18 |
+
# fall back; only error if a DB function is actually called
|
| 19 |
+
mysql = None
|
| 20 |
+
|
| 21 |
+
|
| 22 |
# password hashing
|
| 23 |
import bcrypt
|
| 24 |
|