diff --git a/src/regtech_user_fi_management/entities/engine/engine.py b/src/regtech_user_fi_management/entities/engine/engine.py index 0b32711..fcdecb4 100644 --- a/src/regtech_user_fi_management/entities/engine/engine.py +++ b/src/regtech_user_fi_management/entities/engine/engine.py @@ -1,16 +1,13 @@ from sqlalchemy import create_engine -from sqlalchemy.orm import scoped_session, sessionmaker +from sqlalchemy.orm import sessionmaker from regtech_user_fi_management.config import settings engine = create_engine(str(settings.inst_conn), echo=settings.db_logging).execution_options( schema_translate_map={None: settings.inst_db_schema} ) -SessionLocal = scoped_session(sessionmaker(engine, expire_on_commit=False)) +SessionLocal = Session = sessionmaker(engine, expire_on_commit=False) def get_session(): - session = SessionLocal() - try: + with Session() as session: yield session - finally: - session.close()