Hello;
I tried to display the contents of my "loc35R" table in a Widget table that was created by QtDesigner.
the display looks good, but with disordered dates.
I tried to display with a selection of dates in descending order, but it did not work
here is the code simplifies the functions used for this :
creation of the database and the table :
thanks for help
I tried to display the contents of my "loc35R" table in a Widget table that was created by QtDesigner.
the display looks good, but with disordered dates.
I tried to display with a selection of dates in descending order, but it did not work
![[Image: w2ki.png]](https://zupimages.net/up/19/46/w2ki.png)
here is the code simplifies the functions used for this :
creation of the database and the table :
def create_database_and_table(self): monitor1=self.lineEdit_monitor1.text() monitor2=self.lineEdit_monitor2.text() date_releves = self.lineEdit_date.text() connexion = sqlite3.connect('ils35R.db') curseur = connexion.cursor() curseur.execute('''CREATE TABLE IF NOT EXISTS loc35R (date_releves_reading text text, monitor1_reading text, monitor2_reading text) ''') curseur.execute('''INSERT INTO rloc35R VALUES (?,?,?) ''',(date_releves, monitor1, monitor2)) connexion.commit() curseur.close() connexion.close()read and display the contents of the table :
def display_table_loc35R(self): conn = sqlite3.connect ('ils35R.db') curseur=conn.cursor() c=curseur.execute("SELECT * FROM loc35R ORDER BY date_releves_reading DESC") liste_table_loc35R=c.fetchall() self.tableWidget_loc35R.setRowCount(len(liste_table_loc35R)) for lignes_loc35R in range(len(liste_table_loc35R)): for colonnes_loc35R in range(3): self.tableWidget_loc35R.setItem(lignes_loc35R,colonnes_loc35R, QTableWidgetItem(liste_table_loc35R[lignes_loc35R][colonnes_loc35R])) self.tableWidget_loc35R.resizeRowsToContents() self.tableWidget_loc35R.resizeColumnsToContents() curseur.close() conn.close() QtCore.QTimer.singleShot(1000, self.display_table_loc35R)in the picture above, we notice that only days that are sorted in descending order
thanks for help