30 lines
804 B
Python
30 lines
804 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:
|
|
return user_created
|
|
|
|
def getUser(self, username):
|
|
self.__cur.callproc("getUser", (username,))
|
|
return self.__cur.fetchone()
|
|
|
|
|
|
|
|
|