Hello,
I have a Database that stores Categories and their low Quantity Values. I have a SELECT statement that gets all the categories from the database and I'm trying to add the returned results to my combo box.
The only problem is the results are being returned as a tuple and not a string or a list of strings, therefore it's not compatible with the comboBox.
Code Snippet:
Thanks in advance.
I have a Database that stores Categories and their low Quantity Values. I have a SELECT statement that gets all the categories from the database and I'm trying to add the returned results to my combo box.
The only problem is the results are being returned as a tuple and not a string or a list of strings, therefore it's not compatible with the comboBox.
Code Snippet:
#---------------------------------------------------------------------------------------------------- # Values for Categories #---------------------------------------------------------------------------------------------------- # self.CategoryInput.addItems(CategoryList) #Connect to the Category database connection = sqlite3.connect(CategoryDatabase) cursor = connection.cursor() cursor.execute(''' SELECT Category From Categories ''') connection.commit() CategoryList = cursor.fetchall() #Close the connection connection.close() print(CategoryList) self.CategoryInput.addItems(CategoryList)Output:
Output:[('N/A',), ('---',), ('---',), ('---',), ('---',), ('---',), ('---',), ('---',), ('---',), ('---',), ('---',), ('---',), ('---',), ('---',), ('---',), ('---',), ('---',), ('---',), ('---',), ('---',), ('---',)]
Traceback (most recent call last):
line 215,
self.CategoryInput.addItems(CategoryList)
TypeError: index 0 has type 'tuple' but 'str' is expected
How do I fix this so I can have all the values printed appear in my CategoryInput ComboBox?Thanks in advance.