def getEmployees(self): with sqlite3.connect("test2.db") as conn: query = 'select empid from employees where "salaryint" = "Monthly" and department <> "Production"' emps = conn.execute(query).fetchall() if emps: self.employees = [ myobjects.Employee(empid[0]) for empid in emps ]
def load_data(self): """ updates the current cell's data. IMPROVEMENT, DONT CALL THIS ON EVERY CELL UPDATE, instead just call datachanged on one cell. """ with sqlite3.connect('test2.db') as conn: employeeids = conn.execute( 'select empid from employees where department =:dep', {'dep': self.department}) self.employees = [ myobjects.Employee(empid[0]) for empid in employeeids.fetchall() ] for employee in self.employees: employee.setAttendanceDict(self.month, self.year) employee.setAttendanceHalf(self.month, self.half)
def setTransactions(self): with sqlite3.connect('test2.db') as conn: # {'empids':self.empids, 'startdate': f"{self.startyear}-{self.startmonth:02}-{self.startday:02}" ,'enddate': f"{self.endyear}-{self.endmonth:02}-{self.endday:02}"} query = f"SELECT * FROM transactions WHERE empid in ({','.join(['?'] * len(self.empids))}) and date between '{self.startdate}' and '{self.enddate} order by date desc'" self.transactiondata = conn.execute(query, self.empids).fetchall() # transactiondata = conn.execute('select * from transactions where empid in (:empids) and date between :startdate and :enddate',{'startdate':self.startdate,'enddate':self.enddate,'empids':self.empids}) self.displaydata = [] for x in self.transactiondata: tmp = {} tmp['transid'] = x[0] tmp['empname'] = myobjects.Employee(x[1]).name tmp['date'] = x[2] tmp['amount'] = x[3] self.displaydata.append(tmp) self.headerDataChanged.emit(QtCore.Qt.Horizontal, 0, self.columnCount() - 1)
def __init__(self, employeeid, daterange=[]): super().__init__() self.employee = myobjects.Employee(employeeid) self.getAllTransactions()
def setEmployee(self, empid): self.employee = myobjects.Employee(empid) self.getAllTransactions()
def loadempids(self): with sqlite3.connect("test2.db") as conn: query = "SELECT * FROM loanadjustments where amount > 0" result = conn.execute(query).fetchall() self.employees = [myobjects.Employee(empid) for empid, _ in result]
def initEmployees(self): with sqlite3.connect('test2.db') as conn: empids = conn.execute( 'select empid from employees where department = :dept', {'dept': self.department}) self.employees = [myobjects.Employee(empid[0]) for empid in empids]