summaryrefslogtreecommitdiff
path: root/DBcm.py
diff options
context:
space:
mode:
authorWillem Renes <wrenes@gmail.com>2021-05-12 12:07:27 +0200
committerWillem Renes <wrenes@gmail.com>2021-05-12 12:07:27 +0200
commit6dabf79eba1d9a2bcee77687785280cb9bdd38ac (patch)
tree16d3113e79801b55ceae5d944986d85c5df2bc54 /DBcm.py
parent20abdbd4c66ea086d809aea9be8a8aa8e3eba208 (diff)
downloadvsearchweb-6dabf79eba1d9a2bcee77687785280cb9bdd38ac.tar.gz
vsearchweb-6dabf79eba1d9a2bcee77687785280cb9bdd38ac.zip
updated codeHEADmaster
Diffstat (limited to 'DBcm.py')
-rw-r--r--DBcm.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/DBcm.py b/DBcm.py
new file mode 100644
index 0000000..afe2391
--- /dev/null
+++ b/DBcm.py
@@ -0,0 +1,17 @@
+import mysql.connector
+
+
+class UseDatabase:
+
+ def __init__(self, config: dict) -> None:
+ self.configuration = config
+
+ def __enter__(self) -> 'cursor':
+ self.conn = mysql.connector.connect(**self.configuration)
+ self.cursor = self.conn.cursor()
+ return self.cursor
+
+ def __exit__(self, exc_type, exc_value, exc_trace) -> None:
+ self.conn.commit()
+ self.cursor.close()
+ self.conn.close()