from iDatabase import iDatabase from Mariadb import Mariadb from Employee import Employee class DataManager: def __init__(self, database: iDatabase): self.database = database def getEmployees(self): conn = self.database.connectDb() cur = conn.cursor() sql = 'select * from employees' cur.execute(sql) employeeList = [] for (id, name, city, salary) in cur: employee = Employee(id, name, city, salary) employeeList.append(employee) return employeeList def insertEmployee(self, employee: Employee): conn = self.database.connectDb() cur = conn.cursor() sql = """ insert into employees (name, city, salary) values (?, ?, ?) """ values = (employee.name, employee.city, employee.salary) cur.execute(sql, values) conn.commit() conn.close() if __name__ == '__main__': data_manager = DataManager(Mariadb())