Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
chenpangpang
open-webui
Commits
eb01e8d2
Commit
eb01e8d2
authored
Jun 24, 2024
by
Jonathan Rohde
Browse files
feat(sqlalchemy): use scoped session
parent
c134eab2
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
5 deletions
+5
-5
backend/apps/webui/internal/db.py
backend/apps/webui/internal/db.py
+5
-5
No files found.
backend/apps/webui/internal/db.py
View file @
eb01e8d2
...
@@ -7,7 +7,7 @@ from typing_extensions import Self
...
@@ -7,7 +7,7 @@ from typing_extensions import Self
from
sqlalchemy
import
create_engine
,
types
,
Dialect
from
sqlalchemy
import
create_engine
,
types
,
Dialect
from
sqlalchemy.ext.declarative
import
declarative_base
from
sqlalchemy.ext.declarative
import
declarative_base
from
sqlalchemy.orm
import
sessionmaker
from
sqlalchemy.orm
import
sessionmaker
,
scoped_session
from
sqlalchemy.sql.type_api
import
_T
from
sqlalchemy.sql.type_api
import
_T
from
config
import
SRC_LOG_LEVELS
,
DATA_DIR
,
DATABASE_URL
,
BACKEND_DIR
from
config
import
SRC_LOG_LEVELS
,
DATA_DIR
,
DATABASE_URL
,
BACKEND_DIR
...
@@ -61,10 +61,10 @@ Base = declarative_base()
...
@@ -61,10 +61,10 @@ Base = declarative_base()
@
contextmanager
@
contextmanager
def
get_session
():
def
get_session
():
db
=
SessionLocal
(
)
session
=
scoped_session
(
SessionLocal
)
try
:
try
:
yield
db
yield
session
db
.
commit
()
session
.
commit
()
except
Exception
as
e
:
except
Exception
as
e
:
db
.
rollback
()
session
.
rollback
()
raise
e
raise
e
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment