aboutsummaryrefslogtreecommitdiff
path: root/gn3/auth/db.py
diff options
context:
space:
mode:
authorFrederick Muriuki Muriithi2022-11-15 04:22:17 +0300
committerFrederick Muriuki Muriithi2022-11-15 04:22:17 +0300
commitb0d4aeb29c059c6dea85a7993149fa1e0697f702 (patch)
tree301bd3db1bb25cf622c7f83c6773e1ac5711ae7e /gn3/auth/db.py
parent9aee64c5bccae917ab0e65c882be8f442fc0f5ca (diff)
downloadgenenetwork3-b0d4aeb29c059c6dea85a7993149fa1e0697f702.tar.gz
pylint: Fix linting errors.
Diffstat (limited to 'gn3/auth/db.py')
-rw-r--r--gn3/auth/db.py18
1 files changed, 13 insertions, 5 deletions
diff --git a/gn3/auth/db.py b/gn3/auth/db.py
index c0d0415..e732a03 100644
--- a/gn3/auth/db.py
+++ b/gn3/auth/db.py
@@ -4,16 +4,24 @@ import contextlib
@contextlib.contextmanager
def connection(db_path: str):
- connection = sqlite3.connect(db_path)
+ """Create the connection to the auth database."""
+ conn = sqlite3.connect(db_path)
try:
- yield connection
+ yield conn
+ except: # pylint: disable=bare-except
+ conn.rollback()
finally:
- connection.close()
+ conn.commit()
+ conn.close()
@contextlib.contextmanager
-def cursor(connection):
- cur = connection.cursor()
+def cursor(conn):
+ """Get a cursor from the given connection to the auth database."""
+ cur = conn.cursor()
try:
yield cur
+ except: # pylint: disable=bare-except
+ conn.rollback()
finally:
+ conn.commit()
cur.close()