aboutsummaryrefslogtreecommitdiff
path: root/gn3/auth/db.py
diff options
context:
space:
mode:
authorFrederick Muriuki Muriithi2022-11-14 18:04:08 +0300
committerFrederick Muriuki Muriithi2022-11-14 18:04:08 +0300
commit6b964b95a67bac69a1217b3f9c39c58a19881df4 (patch)
treef83ac08fa06c7535c1fcb3926876029e2ec17a52 /gn3/auth/db.py
parentbaf7980cd6080c8cb4e6c6b585948144273600aa (diff)
downloadgenenetwork3-6b964b95a67bac69a1217b3f9c39c58a19881df4.tar.gz
auth: Implement `create_group`
Diffstat (limited to 'gn3/auth/db.py')
-rw-r--r--gn3/auth/db.py19
1 files changed, 19 insertions, 0 deletions
diff --git a/gn3/auth/db.py b/gn3/auth/db.py
new file mode 100644
index 0000000..c0d0415
--- /dev/null
+++ b/gn3/auth/db.py
@@ -0,0 +1,19 @@
+"""Handle connection to auth database."""
+import sqlite3
+import contextlib
+
+@contextlib.contextmanager
+def connection(db_path: str):
+ connection = sqlite3.connect(db_path)
+ try:
+ yield connection
+ finally:
+ connection.close()
+
+@contextlib.contextmanager
+def cursor(connection):
+ cur = connection.cursor()
+ try:
+ yield cur
+ finally:
+ cur.close()