hi; I try to display the cotent of my database between two dates but I have somme problems.
there is the code of the function with which I want to display database content between two dates.
I associate a pushbutton to this function like this:
self.pushbutton_select.clicked.connect(self.select_by_dates )
the result is error display at the terminal.
but if I modify the code at the line 10 ,by changing for example :
start_date by ‘01-12-2019’ and end_date by ‘20-12-2019’
the code work well and show me what I want
I would love to have help and explanation of this
thanks
there is the code of the function with which I want to display database content between two dates.
def select_by_dates (self): start_date =self.lineEdit_start_date.text() end_date = self.lineEdit_end_date.text() try : conn = sqlite3.connect ('correction.db') curseur=conn.cursor() c=curseur.execute("SELECT * FROM correction_loc35R WHERE date_correction BETWEEN start_date AND end_date ") 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")for information, the type of 'start_date' and 'end_date' is string and like this format (day-month-year)
I associate a pushbutton to this function like this:
self.pushbutton_select.clicked.connect(self.select_by_dates )
the result is error display at the terminal.
but if I modify the code at the line 10 ,by changing for example :
start_date by ‘01-12-2019’ and end_date by ‘20-12-2019’
the code work well and show me what I want
I would love to have help and explanation of this
thanks