Files
pyqcrm/lib/DB/UserDAO.py
2024-12-10 09:27:55 +01:00

33 lines
929 B
Python

# This Python file uses the following encoding: utf-8
from .DbManager import DbManager
from ..PyqcrmFlags import PyqcrmFlags
import mariadb
class UserDAO:
def __init__(self):
self.__con = DbManager().getConnection()
self.__cur = self.__con.cursor()
def createUser(self, username, password, info, role= PyqcrmFlags.USER):
user_created = True
try:
self.__cur.callproc("createUser", (username, password, info, role))
self.__con.commit()
except mariadb.Error as e:
print(f"Error: {e}")
print(e.errno)
user_created = False
finally:
# self.__closeConnection()
return user_created
def getUser(self, username):
self.__cur.callproc("getUser", (username,))
return self.__cur.fetchone()
def __closeConnection(self):
self.__cur.close()
self.__con.close()