def find(self, clinic_id): c = self._dbcon.cursor() c.execute( """ SELECT id, name FROM clinics WHERE id = ? """, [clinic_id]) return DTO.Clinics(*c.fetchone())
def read_insert(self, config_file): with open(config_file) as f: f = f.readlines() # f stands for file -- make my file a list config_first_line = f[0] config_first_line = config_first_line[:-1] split_config_first_line = config_first_line.split(",") list_entries_vaccines = [] list_entries_suppliers = [] list_entries_clinics = [] list_entries_logistics = [] lines_to_read_vac = int(split_config_first_line[0]) lines_to_read_sup = int(split_config_first_line[1]) lines_to_read_clin = int(split_config_first_line[2]) lines_to_read_log = int(split_config_first_line[3]) range1 = range(1, 1 + lines_to_read_vac) range2 = range(1 + lines_to_read_vac, lines_to_read_sup + 1 + lines_to_read_vac) range3 = range( lines_to_read_sup + 1 + lines_to_read_vac, lines_to_read_sup + 1 + lines_to_read_vac + lines_to_read_clin) range4 = range( lines_to_read_sup + 1 + lines_to_read_vac + lines_to_read_clin, lines_to_read_sup + 1 + lines_to_read_vac + lines_to_read_clin + lines_to_read_log) for i in range1: list_entries_vaccines.append(f[i]) for i in range2: list_entries_suppliers.append(f[i]) for i in range3: list_entries_clinics.append(f[i]) for i in range4: list_entries_logistics.append(f[i]) for i in list_entries_vaccines: i = i[:-1] i = i.split(',') vaccine = DTO.Vaccines(*i) insert_vac = DAO.Vaccines(self._dbcon) insert_vac.insert(vaccine) for i in list_entries_suppliers: i = i[:-1] i = i.split(',') supplier = DTO.Suppliers(*i) insert_sup = DAO.Suppliers(self._dbcon) insert_sup.insert(supplier) for i in list_entries_clinics: i = i[:-1] i = i.split(',') clinic = DTO.Clinics(*i) insert_cli = DAO.Clinics(self._dbcon) insert_cli.insert(clinic) for i in list_entries_logistics: if i[-1] == '\n': i = i[:-1] i = i.split(',') logistic = DTO.Logistic(*i) insert_log = DAO.Logistics(self._dbcon) insert_log.insert(logistic)