mirror of
https://gitlab.archlinux.org/archlinux/aurweb.git
synced 2025-02-03 10:43:03 +01:00
feat(FastAPI): use SQLAlchemy's scoped_session
Closes #113 Signed-off-by: Kevin Morris <kevr@0cost.org>
This commit is contained in:
parent
f6141ff177
commit
b5f8e69b8a
1 changed files with 3 additions and 1 deletions
|
@ -3,6 +3,7 @@ import math
|
|||
import re
|
||||
|
||||
from sqlalchemy import event
|
||||
from sqlalchemy.orm import scoped_session
|
||||
|
||||
import aurweb.config
|
||||
import aurweb.util
|
||||
|
@ -167,7 +168,8 @@ def get_engine(echo: bool = False):
|
|||
connect_args=connect_args,
|
||||
echo=echo)
|
||||
|
||||
Session = sessionmaker(autocommit=True, autoflush=False, bind=engine)
|
||||
Session = scoped_session(
|
||||
sessionmaker(autocommit=True, autoflush=False, bind=engine))
|
||||
session = Session()
|
||||
|
||||
if db_backend == "sqlite":
|
||||
|
|
Loading…
Add table
Reference in a new issue