Python Forum
[PyQt] [Solved]Help displaying SQLite Database
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[PyQt] [Solved]Help displaying SQLite Database
#8
(May-20-2022, 08:40 AM)Axel_Erfurt Wrote:
(May-19-2022, 11:34 PM)Extra Wrote: Here's the table (called items) that was created:

Ok, that works for me after changing self.tableWidget to self.InventoryDisplay in loaddata

self.tableWidget was never defined

    def loaddata(self):
        connection = sqlite3.connect("inventory.db")
        cursor = connection.cursor()
        cursor.execute('select * from items')
 
        tablerow=0
        results = cursor.fetchall()
        self.InventoryDisplay.setRowCount(40)
        for row in results:
            self.InventoryDisplay.setItem(tablerow, 0, QtWidgets.QTableWidgetItem(row[0]))
            self.InventoryDisplay.setItem(tablerow, 1, QtWidgets.QTableWidgetItem(row[1]))
            self.InventoryDisplay.setItem(tablerow, 2, QtWidgets.QTableWidgetItem(row[2]))
            tablerow+=1
        connection.close()
        #---------------------------------------------------------------------
   
        self.retranslateUi(self)
        QMetaObject.connectSlotsByName(self)

Thanks, that got my table to display. The only problem is that just the item's name is displayed there is other other information there even through there's supposed to be.

For ex I added the following info to the items table:
NAME MG996R
Quantity 10
Price 5
Sell_Price 6
Description A Servo
Category Servos
Location S-1
Length_Ft
Barcode
Image
Date Updated

But all I get outputted to the table is the item Name:
MG996R
Nothing else.


My question is, why isn't the other info showing?
Reply


Messages In This Thread
[Solved]Help displaying SQLite Database - by Extra - May-19-2022, 01:19 AM
RE: Help displaying SQLite Database - by Extra - May-19-2022, 11:34 PM
RE: Help displaying SQLite Database - by Extra - May-20-2022, 11:24 PM
RE: Help displaying SQLite Database - by Larz60+ - May-20-2022, 12:09 PM
RE: Help displaying SQLite Database - by Extra - May-21-2022, 08:03 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  PyQt5 form not displaying my data from SQLite3 Database Linuxdesire 2 5,098 Jan-10-2023, 09:51 PM
Last Post: gradlon93
  [PyQt] [Solved]Help displaying a table with QSqlTableModel Extra 10 3,069 Jun-29-2022, 10:18 PM
Last Post: Extra
  Displaying database info in QTableWidget thewolf 6 5,547 Apr-03-2021, 02:49 PM
Last Post: thewolf
  [Tkinter] Displaying Data from a database and run a function when clicked? PythonNPC 1 2,138 Mar-11-2020, 08:16 PM
Last Post: Larz60+

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020