def __init__(self, db): try: self.old_db = man.DBManager(db) self.temp_db = self.old_db.dbTransfer() try: self.old_db.deleteDB() except PermissionError: print('File In Use.') self.new_db = man.DBManager.setUp(db, tbl.getModelSchema()[0], tbl.getModelSchema()[1]) except Exception as e: print(e) print('Update Failed. Reverting Changes') self.old_db = self.temp_db.dbTransfer(to=db)
def config(self,temp_db=False): #Arg Parsing arg_field = startUp() if not arg_field[1] and not temp_db: self.db = man.DBManager(self.db_path) else: m_format = tbl.getModelSchema() self.db = man.DBManager.setUp('',m_format[0],m_format[1]) #Manager SetUp self.sig = man.sigManager() if arg_field[0]: self.sig.trk.track() self.pm = man.PayManager(self.db,self.sig,co='co',r='ra',ca='ca',j='jo',pl='pl') #Model SetUp try: co_model = tbl.CompanyModel(self.db,self.sig) co_model.loadData() r_model = tbl.RateModel(self.db,co_model,self.sig) r_model.loadData() j_model = tbl.JobModel(self.db,co_model,r_model,self.sig,self.pm) j_model.loadData() ca_model = tbl.CallModel(self.db,co_model,r_model,j_model,self.sig,self.pm) ca_model.loadData() pl_model = tbl.PayLevelModel(self.db,r_model,self.sig,self.pm) pl_model.loadData() self.models = {'co':co_model,'ra':r_model,'jo':j_model,'ca':ca_model,'pl':pl_model} #Widget SetUp data_tab = QTabWidget() data_tab.addTab(comp.GenericEntryTab(self.models,0,size=(self.size[0],self.size[1]-200)),'Companies') data_tab.addTab(comp.GenericEntryTab(self.models,1,size=(self.size[0],self.size[1]-200)),'Rates') data_tab.addTab(comp.GenericEntryTab(self.models,2,size=(self.size[0],self.size[1]-200)),'Jobs') data_tab.addTab(comp.GenericEntryTab(self.models,3,size=(self.size[0],self.size[1]-200)),'Calls') nav_tab = QTabWidget() nav_tab.addTab(data_tab,'Data') self.setCentralWidget(nav_tab) except Exception as e: print(e) self.new()
def __init__(self, parent=None): super().__init__(parent) #Arg Parsing arg_field = startUp() if not arg_field[1]: self.db = man.DBManager('m_test') else: m_format = tbl.getModelSchema() self.db = man.DBManager.setUp('', m_format[0], m_format[1]) #Manager SetUp sig = man.sigManager() if arg_field[0]: sig.trk.track() self.pm = man.PayManager(self.db, sig, co='co', r='ra', ca='ca', j='jo') #Model SetUp co_model = tbl.CompanyModel(self.db, sig) co_model.loadData() r_model = tbl.RateModel(self.db, co_model, sig) r_model.loadData() j_model = tbl.JobModel(self.db, co_model, r_model, sig, self.pm) j_model.loadData() ca_model = tbl.CallModel(self.db, co_model, r_model, j_model, sig, self.pm) ca_model.loadData() #Table SetUp models = {'co': co_model, 'ra': r_model, 'jo': j_model, 'ca': ca_model} self.co_tab = comp.GenericEntryTab(models, 3) #Layout self.grid = QHBoxLayout() self.setLayout(self.grid) self.grid.addWidget(self.co_tab) self.show()
def __init__(self, parent=None): super().__init__(parent) arg_field = self.startUp() if not arg_field[1]: self.db = man.DBManager( 'E:\Projects\Python\HourMaster\HM_A2-5\db\\l_test.db') else: m_format = tbl.getModelSchema() self.db = man.DBManager.setUp('', m_format[0], m_format[1]) sig = man.sigManager() if arg_field[0]: sig.trk.track() self.pm = man.PayManager(self.db, sig, co='co', r='ra', ca='ca', j='jo') co_model = tbl.CompanyModel(self.db, sig) co_model.loadData() self.co_table = tbl.CompanyTable(co_model) r_model = tbl.RateModel(self.db, co_model, sig) r_model.loadData() self.r_table = tbl.RateTable(r_model) self.r_table.setProxy(comp.ReferencedFilter(self.co_table, 1)) j_model = tbl.JobModel(self.db, co_model, r_model, sig, self.pm) j_model.loadData() self.j_table = tbl.JobTable(j_model) self.j_table.setProxy(comp.ReferencedFilter(self.r_table, 2)) ca_model = tbl.CallModel(self.db, co_model, r_model, j_model, sig, self.pm) ca_model.loadData() self.ca_table = tbl.CallTable(ca_model) self.ca_table.setProxy(comp.ReferencedFilter(self.co_table, 2)) self.grid = QHBoxLayout() self.setLayout(self.grid) self.grid.addWidget(self.co_table) self.grid.addWidget(self.r_table) self.grid.addWidget(self.j_table) self.grid.addWidget(self.ca_table) self.show()
def encodeCSV(self): co_data = self.db.selectTable('co') r_data = self.db.selectTable('ra') j_data = self.db.selectTable('jo') pl_data = self.db.selectTable('pl') ca_data = self.db.selectTable('ca') with open(self.to, 'a') as csv_file: writer = csv.writer(csv_file) schema = tbl.getModelSchema()[1] writer.writerow([col[0] for col in schema[0]]) writer.writerows(co_data) writer.writerow([col[0] for col in schema[1]]) writer.writerows(r_data) writer.writerow([col[0] for col in schema[2]]) writer.writerows(j_data) writer.writerow([col[0] for col in schema[4]]) writer.writerows(pl_data) writer.writerow([col[0] for col in schema[3]]) writer.writerows(ca_data)
def configDB(self): m_format = tbl.getModelSchema() db = man.DBManager.setUp('', m_format[0], m_format[1]) return db
def setUp(cls): m_format = tbl.getModelSchema() setUpDB = man.DBManager.setUp('m_test', m_format[0], m_format[1]) return cls()
#Layout self.grid = QHBoxLayout() self.setLayout(self.grid) self.grid.addWidget(self.co_tab) self.show() def setUp(cls): m_format = tbl.getModelSchema() setUpDB = man.DBManager.setUp('m_test', m_format[0], m_format[1]) return cls() def startUp(): arg_field = [0, 0] args = sys.argv[1:] if '--track' in args or '-t' in args: arg_field[0] = 1 if '--new' in args or '-n' in args: arg_field[1] = 1 return arg_field if __name__ == '__main__': man.DBManager.setUp('E:\Projects\Python\HourMaster\HM_A2-5\db\\l_test.db', tbl.getModelSchema()[0][:-1], tbl.getModelSchema()[1][:-1]) app = QApplication(sys.argv) win = RefTestWindow() app.exec_()