Spaces:
Sleeping
Sleeping
Fix SyntaxError by moving global engine statement to function beginning
Browse files- app/database.py +2 -1
app/database.py
CHANGED
@@ -408,6 +408,8 @@ def get_current_database():
|
|
408 |
|
409 |
# Create tables
|
410 |
def create_tables():
|
|
|
|
|
411 |
try:
|
412 |
# Create all tables (only creates tables that don't exist)
|
413 |
Base.metadata.create_all(bind=engine)
|
@@ -433,7 +435,6 @@ def create_tables():
|
|
433 |
print(f"Created new database file: {db_path}")
|
434 |
|
435 |
# Recreate engine with the new database
|
436 |
-
global engine
|
437 |
engine.dispose()
|
438 |
engine = create_engine(f"sqlite:///{db_path}", connect_args={"check_same_thread": False})
|
439 |
|
|
|
408 |
|
409 |
# Create tables
|
410 |
def create_tables():
|
411 |
+
global engine # Declare global at the beginning
|
412 |
+
|
413 |
try:
|
414 |
# Create all tables (only creates tables that don't exist)
|
415 |
Base.metadata.create_all(bind=engine)
|
|
|
435 |
print(f"Created new database file: {db_path}")
|
436 |
|
437 |
# Recreate engine with the new database
|
|
|
438 |
engine.dispose()
|
439 |
engine = create_engine(f"sqlite:///{db_path}", connect_args={"check_same_thread": False})
|
440 |
|