def find(self, vaccine_id): c = self._conn.cursor() c.execute( """ SELECT * FROM vaccines WHERE id = ? """, [vaccine_id]) #print(type(*c.fetchone())) return DTO.vaccines(*c.fetchone())
def receive_shipment(self, name, amount, date): cursor = self._conn.cursor() # cursor.execute("SELECT * FROM vaccines ORDER BY id DESC LIMIT 1") if (self.are_any_vaccine_left() == True): cursor.execute("""SELECT MAX(id) FROM vaccines""") last = cursor.fetchone()[0] + 1 else: last = 1 cursor.execute("""SELECT id FROM suppliers WHERE name=(?)""", [name]) supp_id = cursor.fetchone()[0] amount = int(amount) # TODO: make this object datetime # date = datetime.strptime(date, '%Y-%m-%d') vaccine_to_add = DTO.vaccines(last, date, supp_id, amount) adding_vaccine = DAO._vaccines(cursor) adding_vaccine.insert(vaccine_to_add) self.update_logistics_count_received(supp_id, amount)
def populate_db(self, vacs, sups, clis, logs): for i in vacs: i = i.split(',') vaccine = DTO.vaccines(*i) insert_vac = DAO._vaccines(self._conn) insert_vac.insert(vaccine) for i in sups: i = i.split(',') supplier = DTO.suppliers(*i) insert_sup = DAO._suppliers(self._conn) insert_sup.insert(supplier) for i in clis: i = i.split(',') clinic = DTO.clinics(*i) insert_clinic = DAO._clinics(self._conn) insert_clinic.insert(clinic) for i in logs: i = i.split(',') logistic = DTO.logistics(*i) insert_logistic = DAO._logistics(self._conn) insert_logistic.insert(logistic)