feat(sqlalchemy): use session factory instead of context manager

This commit is contained in:
Jonathan Rohde
2024-06-24 13:06:15 +02:00
parent eb01e8d275
commit da403f3e3c
15 changed files with 640 additions and 759 deletions

View File

@@ -57,14 +57,4 @@ SessionLocal = sessionmaker(
autocommit=False, autoflush=False, bind=engine, expire_on_commit=False
)
Base = declarative_base()
@contextmanager
def get_session():
session = scoped_session(SessionLocal)
try:
yield session
session.commit()
except Exception as e:
session.rollback()
raise e
Session = scoped_session(SessionLocal)