primer commit

This commit is contained in:
Marvin Vallecillo
2024-04-11 02:24:26 -06:00
commit bd0eef8998
19 changed files with 373 additions and 0 deletions
View File
Binary file not shown.
+16
View File
@@ -0,0 +1,16 @@
import mysql.connector
class ConnMysql:
def __init__(self, ret="conn", **kwargs):
self.ret = ret
self.conn = mysql.connector.connect(**kwargs, autocommit=False)
if ret == "cursor":
self.cursor = self.conn.cursor()
def __enter__(self):
return self.cursor if self.ret == "cursor" else self.conn
def __exit__(self, exc_type, exc_val, exc_tb):
if self.ret == "cursor":
self.cursor.close()
self.conn.__exit__(exc_type, exc_val, exc_tb)