28 lines
755 B
Python
28 lines
755 B
Python
from .DbManager import DbManager
|
|
import json
|
|
import mariadb
|
|
|
|
|
|
class ContactDAO:
|
|
def __init__(self):
|
|
print(f"*** File: {__file__}, __init__()")
|
|
self.__con = DbManager().getConnection()
|
|
self.__cur = self.__con.cursor()
|
|
|
|
def getContacts(self):
|
|
print(f"*** File: {__file__}, getContacts()")
|
|
|
|
def addContact(self, contact):
|
|
try:
|
|
self.__cur.callproc("addContactPerson", (json.dumps(contact),))
|
|
self.__con.commit()
|
|
self.__cur.callproc("getLastInsertId")
|
|
contact_id = self.__cur.fetchone()
|
|
return contact_id[0]
|
|
except mariadb.Error as e:
|
|
print("MDB: " + str(e))
|
|
except Exception as e:
|
|
print("PYT: " + str(e))
|
|
|
|
|