From b36326d1a5c193fc3099f0b8d5c45156abb83704 Mon Sep 17 00:00:00 2001 From: Automated Action Date: Tue, 3 Jun 2025 10:43:26 +0000 Subject: [PATCH] Fix SyntaxError: move global declarations before variable usage in get_db function --- app/db/session.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/db/session.py b/app/db/session.py index beb089d..1a22b45 100644 --- a/app/db/session.py +++ b/app/db/session.py @@ -105,10 +105,11 @@ except Exception as e: # Dependency to get DB session def get_db(): """FastAPI dependency for database sessions with error handling.""" + global engine, SessionLocal + if not SessionLocal: logger.error("Database session not initialized, attempting to initialize") # Last chance to initialize - global engine, SessionLocal try: engine = create_engine("sqlite://", connect_args={"check_same_thread": False}) SessionLocal = sessionmaker(autocommit=False, autoflush=False, bind=engine)