diff options
Diffstat (limited to 'db/session.py')
| -rw-r--r-- | db/session.py | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/db/session.py b/db/session.py index 4d83649..ec700bd 100644 --- a/db/session.py +++ b/db/session.py | |||
| @@ -17,5 +17,10 @@ def get_session(): | |||
| 17 | yield session | 17 | yield session |
| 18 | 18 | ||
| 19 | @contextmanager | 19 | @contextmanager |
| 20 | def get_session_context(): | 20 | def get_session_context(autocommit=True): |
| 21 | yield from get_session() | 21 | session = next(get_session()) |
| 22 | |||
| 23 | yield session | ||
| 24 | |||
| 25 | if autocommit: | ||
| 26 | session.commit() | ||
