0

(using python) In my section "Def display_record():" I can not get the messagebox.showinfo(results) to pop up and show the result.

The error I get is "Expected type 'str | None', got 'list' instead" I tried a couple different version with my fetchall() to see if I needed to make it a list before going into message box. However that did not work. Not sure what the issue is.

The result I should be getting from my products.db. An example of the values are: ("INSERT INTO PRODUCTS VALUES (1, 'Hardware', 'Grommets', 1.99, 25)") They are broken up by (ID, PRODCATEGORY, PRODNAME, PRICE, ONHAND)

def display_record():
    try:
        product = (Product_text.get())
        sql_insert_command = ''' SELECT * FROM products WHERE PRODNAME = ?'''
        cursor.execute(sql_insert_command, (product))
        result = (cursor.fetchall())
        messagebox.showinfo(result)
    except:
        messagebox.showerror('Failed!')
Riki
  • 9
  • 3
  • 1
    Try messagebox.showinfo(result[0]) – Сергей Кох Oct 14 '22 at 08:14
  • @СергейКох is half right! The 1st positional argument to `showinfo()` sets the *title* of the message box while the 2nd arg sets the message. So what you probably want is `messagebox.showinfo('message title', result[0])` – JRiggles Oct 14 '22 at 12:16

0 Answers0