I don't understand what you want me to do ; but I want you if it possible to clarify to me the differnce between this two codes :
first code that works :
first code that works :
def select_by_dates (self): try : conn = sqlite3.connect ('correction.db') curseur=conn.cursor() curseur.execute("SELECT * FROM correction_loc35R where date_correction between '01-12-2019' AND '28-12-2019' ORDER BY date_correction DESC") liste_select_by_dates_correction=c.fetchall() nbr_rows=len(liste_select_by_dates_correction) if nbr_rows != 0 : # set row count self.tableWidget_select_by_dates_correction.setRowCount(nbr_rows) for nb in range(nbr_rows): for nombre in range(10): self.tableWidget_select_by_dates_correction.setItem(nb,nombre, QTableWidgetItem(liste_select_by_dates_correction[nb][nombre])) self.tableWidget_select_by_dates_correction.resizeRowsToContents() self.tableWidget_select_by_dates_correction.resizeColumnsToContents() conn.commit() curseur.close() conn.close() else : print("OK") except : print("error")second code that doesn't work :
def select_by_dates (self): start_date ='01-12-2019' end_date = '28-12-2019' try : conn = sqlite3.connect ('correction.db') curseur=conn.cursor() curseur.execute("SELECT * FROM correction_loc35R where date_correction between start_date AND end_date ORDER BY date_correction DESC") liste_select_by_dates_correction=c.fetchall() nbr_rows=len(liste_select_by_dates_correction) if nbr_rows != 0 : # set row count self.tableWidget_select_by_dates_correction.setRowCount(nbr_rows) for nb in range(nbr_rows): for nombre in range(10): self.tableWidget_select_by_dates_correction.setItem(nb,nombre, QTableWidgetItem(liste_select_by_dates_correction[nb][nombre])) self.tableWidget_select_by_dates_correction.resizeRowsToContents() self.tableWidget_select_by_dates_correction.resizeColumnsToContents() conn.commit() curseur.close() conn.close() else : print("OK") except : print("error")and yet the two codes are pretty much the same