Update project files

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
ANDREW HOSFORD
2026-04-07 11:59:48 -05:00
parent dd227be9b0
commit 0e8978f48c
50 changed files with 5878 additions and 241 deletions

View File

@@ -20,3 +20,14 @@ def get_db():
yield db
finally:
db.close()
def switch_database(db_path: Path):
"""Hot-swap the active database engine and session factory."""
global engine, SessionLocal, DB_PATH
DB_PATH = db_path
engine.dispose()
engine = create_engine(f"sqlite:///{db_path}", echo=False)
SessionLocal = sessionmaker(bind=engine, class_=Session, expire_on_commit=False)
Base.metadata.create_all(bind=engine)
return engine