Spaces:
Sleeping
Sleeping
Update database.py
Browse files- database.py +6 -0
database.py
CHANGED
|
@@ -31,6 +31,12 @@ def close_db(e=None):
|
|
| 31 |
if db is not None:
|
| 32 |
db.close()
|
| 33 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 34 |
def init_db():
|
| 35 |
"""Initialize database with required tables"""
|
| 36 |
try:
|
|
|
|
| 31 |
if db is not None:
|
| 32 |
db.close()
|
| 33 |
|
| 34 |
+
def get_db_connection():
|
| 35 |
+
"""Get a new database connection (for use outside Flask context)"""
|
| 36 |
+
conn = sqlite3.connect(DATABASE_PATH)
|
| 37 |
+
conn.row_factory = sqlite3.Row
|
| 38 |
+
return conn
|
| 39 |
+
|
| 40 |
def init_db():
|
| 41 |
"""Initialize database with required tables"""
|
| 42 |
try:
|