def populate_equipment_table(self):
        conn = create_connection()
        if not conn:
            messagebox.showerror("Connection Error", "Failed to connect to the database.")
        else:
            try:
                cursor = conn.cursor()
                query = """
                        SELECT e.Name, p.Name, pe.Quantity
                        FROM Equipment e
                        JOIN Practical_Equipment pe ON e.EquipmentID = pe.EquipmentID
                        JOIN Practical p ON pe.PracticalID = p.PracticalID
                        WHERE pe.PracticalID = ?
                        """
                cursor.execute(query, (self.practical_id,))
                rows = cursor.fetchall()

            # Clear existing rows in the treeview
            for i in self.equipment_tree.get_children():
                self.equipment_tree.delete(i)

            # Adding fetched data to the treeview
            for row in rows:
                # Ensure that each row has the correct number of columns
                if len(row) == 3:
                    self.equipment_tree.insert('', tk.END, values=row)
                else:
                    print("Row with incorrect format:", row)
        except sqlite3.Error as e:
            messagebox.showerror("Database Error", "An error occurred: " + str(e))
        finally:
            conn.close()

Treeview for displaying equipment

    self.equipment_tree = ttk.Treeview(self, columns=("Name", "Practical", "Quantity"), show="headings")
    self.equipment_tree.heading("Name", text="Equipment Name")
    self.equipment_tree.heading("Practical", text="Practical Name")
    self.equipment_tree.heading("Quantity", text="Quantity")
    self.equipment_tree.pack(expand=True, fill="both")

IMPLEMENTING THIS TREEVIEW I'M HAVING THIS ERROR Python[59124:2560074] WARNING: Secure coding is not enabled for restorable state! Enable secure coding by implementing NSApplicationDelegate.applicationSupportsSecureRestorableState: and returning YES. objc[59124]: Invalid or prematurely-freed autorelease pool 0x7fe47680ae50. Set a breakpoint on objc_autoreleasePoolInvalid to debug. objc[59124]: Invalid autorelease pools are a fatal error

WHY? CAN SOMEONE HELP PLEASE

SOLVE THIS ISSUE AND TO BE ABLE TO RUN IT CORRECTLY

0

There are 0 best solutions below