Changed database.get file. Added fetchall method calls to close session sooner

This commit is contained in:
StNicolay 2022-12-25 17:59:26 +03:00
parent f299173e56
commit bbc9650357

View File

@ -35,7 +35,7 @@ def get_accounts(
if to_sort: if to_sort:
statement = statement.order_by(models.Account.name) statement = statement.order_by(models.Account.name)
with sqlmodel.Session(engine) as session: with sqlmodel.Session(engine) as session:
result = list(session.exec(statement)) result = session.exec(statement).fetchall()
return result return result
@ -52,7 +52,7 @@ def get_all_accounts(
.order_by(models.Account.name) .order_by(models.Account.name)
) )
with sqlmodel.Session(engine) as session: with sqlmodel.Session(engine) as session:
result = session.exec(statement) result = session.exec(statement).fetchall()
yield from ( yield from (
( (
account.name, account.name,