I am new to Tkinter in Python and I am using it to build a UI for work purposes.
The UI will allow you to search through a list of businesses in a database by either a retailer ID (Integer), retailer name or username.
I have tried searching online and spent ages trying to find what I am looking for on Stackoverflow but can't find what I need.
What I am really struggling with is being able to search by partial strings in the search box and the results to display in a list box. The code below allows me to return a list of businesses but only if I type the EXACT name of the business as it appears in the database.
What I am trying to achieve is, say that there are 2 retailers in the database (these are just examples obviously):
"Market"
"Supermarket"
If I type "Market" in the entry box, I expect to see both of these in the list box. If I type "Super" or "Supermarket", I expect to see only the "Supermarket" retailer name I also don't want this to be case sensitive.
I will then want to be able to select a business from the results and perform some other tasks like sending out automatic emails.
I have access to a MySQL server database.
Here is the code:
# Search businesses
def search_now():
selected = drop.get()
sql = ""
if selected == "Search by...":
searched_label.config(text="You forgot to pick an option!")
if selected == "Business Name":
sql = "SELECT Retailer, Retailer_Name, Account_ID, Password FROM Retailers WHERE Retailer_Name like ?"
searched_label.config(text="Business(s):")
if selected == "Business ID":
sql = "SELECT Retailer, Retailer_Name, Account_ID, Password FROM Retailers WHERE Retailer like ?"
searched_label.config(text="Business(s):")
if selected == "Username":
sql = "SELECT Retailer, Retailer_Name, Account_ID, Password FROM Retailers WHERE Account_ID like ?"
searched_label.config(text="Business(s):")
searched = search_box.get()
#sql = "SELECT Retailer, Retailer_Name, Account_ID, Password FROM Retailers WHERE Retailer_Name like ?"
name = (f'%{searched}%', )
businesses = c.execute(sql, name)
businesses = c.fetchall()
#Clear the listbox
my_list.delete(0, END)
if not businesses:
searched_label.config(text="Business not found")
else:
for business in businesses:
my_list.insert(0, str(business[0]) + " " + business[1] + " " + business[2])
# Entry box to search businesses
search_box = Entry(root)
search_box.grid(row=1, column=1, padx=10, pady=10)
# Entry box label search businesses
search_box_label = Label(root, text="Enter Business name:")
search_box_label.grid(row=1, column=0, padx=1, pady=10)
# Entry box search button for businesses
search_button = Button(root, text="Search", command=search_now)
search_button.grid(row=1, column=4, padx=10, pady=10)
# Drop down box
drop = ttk.Combobox(root, value=["Search by...", "Business Name", "Business ID", "Username"])
drop.current(0)
drop.grid(row=1, column=2)
# Create searched result label
searched_label = Label(root, text="")
searched_label.grid(row=2, column=0, sticky=W, columnspan=2)
# Create a table
title_label = Label(root, text="CRM", font=("Helvetica", 16))
title_label.grid(row=0, column=0, columnspan=2, sticky=W, pady=10)
# Create a listbox
my_list = Listbox(root, width=50)
my_list.grid(row=10, column=0, columnspan=3, sticky=W, pady=10, padx=10)
root.mainloop()
I hope all this information helps!
This is now fixed! The issue was with the way I was searching for a string in the entry box. I needed to use the "f-string" string formatting feature.
Previous error code:
searched = search_box.get()
name = (searched, )
Correct code
searched = search_box.get()
name = (f'%{searched}%', )
Related
In this part of my Python program, I am taking user inputs from Text widgets and inserting them into a pre-existing SQL Server table. The inputs are validated before then being written to the table, however if I try to delete my newly inserted row it is not there. I opened up SQL Server Management Studio and the data doesn't appear to have actually inserted into the table, despite no error when the query was executed.
I'm using Pyodbc, and having already looked around for answers the most common suggestion was to use conn.commit() however I already have this in place, and it isn't solving the problem.
My code relevant to this issue is below:
def gsap_commit():
teams = ["Arsenal", "Aston Villa", "Brentford", "Brighton", "Burnley", "Chelsea", "Crystal Palace", "Everton", "Leeds", "Leicester", "Liverpool",
"Man City", "Man United", "Newcastle", "Norwich", "Southampton", "Tottenham", "Watford", "West Ham", "Wolves"]
gs_fname = gs_ent1.get("1.0", "end-1c")
gs_sname = gs_ent2.get("1.0", "end-1c")
gs_apdob = gs_ent3.get("1.0", "end-1c")
gs_pos = gs_ent4.get("1.0", "end-1c")
gs_team = gs_ent5.get("1.0", "end-1c")
gs_price = gs_ent6.get("1.0", "end-1c")
if gs_fname.isalpha() == True and gs_sname.isalpha() == True:
if int(gs_apdob[5:7]) <= 12 and int(gs_apdob[8:10]) <= 31:
if gs_pos == "GK" or gs_pos == "DEF" or gs_pos == "MID" or gs_pos == "FWD":
if gs_team in teams:
if int(gs_price) > 4.5 and int(gs_price) < 18:
addplayerquery = "INSERT INTO PlayerList(FirstName, Surname, DOB, Position, Team, Price, InitialPrice, TotalPts, InjuryStatus, DoubtStatus) VALUES (?,?,?,?,?,?,?,0,0,0)"
cursor.execute(addplayerquery, gs_fname, gs_sname, gs_apdob, gs_pos, gs_team, gs_price, gs_price)
conn.commit()
tkMessageBox.showinfo("Add Player Successful", "Successfully added player - {0} {1}".format(gs_fname, gs_sname))
else:
tkMessageBox.showinfo("Add Player Unsuccessful", "The price entered was too anomalous.\nPlease re-enter a suitable price")
else:
tkMessageBox.showwarning("Add Player Unsuccessful", "Please enter a valid team name")
else:
tkMessageBox.showwarning("Add Player Unsuccessful", "Please enter a valid position")
else:
tkMessageBox.showwarning("Add Player Unsuccessful", "Please enter a valid birth date")
else:
tkMessageBox.showwarning("Add Player Unsuccessful", "Please enter a valid name")
def gs_add_player():
gs_ent1.configure(state="normal")
gs_ent2.configure(state="normal")
gs_ent3.configure(state="normal")
gs_ent4.configure(state="normal")
gs_ent5.configure(state="normal")
gs_ent6.configure(state="normal")
gs_ent1.delete("1.0",END)
gs_ent1.insert("1.0", "First Name")
gs_ent1.configure(width=20, bd=1)
gs_ent1.focus()
gs_ent2.delete("1.0",END)
gs_ent2.insert("1.0", "Surname")
gs_ent2.configure(width=20, bd=1)
gs_ent3.delete("1.0",END)
gs_ent3.insert("1.0", "DOB ('YYYY-MM-DD')")
gs_ent3.configure(width=20, bd=1)
gs_ent4.delete("1.0",END)
gs_ent4.insert("1.0", "Position")
gs_ent4.configure(width=8, bd=1)
gs_ent5.delete("1.0",END)
gs_ent5.insert("1.0", "Team")
gs_ent5.configure(width=20, bd=1)
gs_ent6.delete("1.0",END)
gs_ent6.insert("1.0", "Price")
gs_ent6.configure(width=5, bd=1)
gs_confirm_bt.configure(text="Add", command=gsap_commit)
gs_addplr_bt = tk.Button(self, text="Add Player", bg="#0ebf08", fg="white", font=("Segoe UI", 12), command=gs_add_player)
gs_ent1 = tk.Text(self, height=1, width=20, bd=2)
gs_ent2 = tk.Text(self, height=1, width=20, bd=2)
gs_ent3 = tk.Text(self, height=1, width=20, bd=2)
gs_ent4 = tk.Text(self, height=1, width=8, bd=2)
gs_ent5 = tk.Text(self, height=1, width=20, bd=2)
gs_ent6 = tk.Text(self, height=1, width=5, bd=2)
gs_ent1.configure(state="disabled")
gs_ent2.configure(state="disabled")
gs_ent3.configure(state="disabled")
gs_ent4.configure(state="disabled")
gs_ent5.configure(state="disabled")
gs_ent6.configure(state="disabled")
gs_confirm_bt = tk.Button(self, text="Add", fg="white", bg="#38003c", width=10)
gs_addplr_bt.grid(row=6, column=2, columnspan=2, sticky="NSEW", pady=(10,10))
gs_ent1.grid(row=11, column=0)
gs_ent2.grid(row=11, column=1)
gs_ent3.grid(row=11, column=2)
gs_ent4.grid(row=11, column=3)
gs_ent5.grid(row=11, column=4)
gs_ent6.grid(row=11, column=5)
gs_confirm_bt.grid(row=12, column=2, columnspan=2, pady=(20,0))
Here is also the code establishing a connection to SQL Server, declared at the start of the program (different class etc. to code above) in case it is useful:
conn = pyodbc.connect("Driver={SQL Server};"
"Server=DESKTOP-MLKS8CG\SQLEXPRESS;"
"Database=FFProject;"
"Trusted_Connection=yes;")
cursor = conn.cursor()
Could anyone please help me understand why my INSERT statement is not appearing to save? Thanks!
I also faced the same issue, for me restarting SQL server worked fine.
I have a Tkinter app and inside that app I have an OptionMenu which is giving me all the id's that are located in the list vehicleid. Please note that this list can become bigger or smaller.
Now I want my button to send the data of owner and vehicleid to a database based on what the user selects. So if I have for example 2 vehicleid's, I first need to select a specific vehicleid and for every vehicleid I need to select a specific owner.
So in case of 2 vehicleid my database should look like this:
vehicleid owner
C161 --- Spain
C162 --- United Kingdom
App looks like this:
This is my code:
owner = ['Spain', 'United Kingdom', 'Malaysia']
vehicleid = ['C161', 'C162']
window = Tk()
window.title("Running Python Script") # Create window
window.geometry('550x300') # Geo of the window
##These are the option menus
dd_owner = StringVar(window)
dd_owner.set(owner[0]) # the first value
w = OptionMenu(window, dd_owner, *owner)
w.grid(row=1, column=1)
dd_id = StringVar(window)
dd_id.set(vehicleid[0])
w0 = OptionMenu(window, dd_id, *vehicleid)
w0.grid(row=0, column=1)
##The run button
run_list_button =Button(window, text="Send data of ID's to database!")
run_list_button.grid(column=0, row=3)
##These are the titles
l1 = Label(window, text='Select Owner', width=15)
l1.grid(row=1, column=0)
l0 = Label(window, text='Select vehicle id:', width = 30)
l0.grid(row=0, column=0)
mainloop()
To begin with, you should store the data somewhere(a dictionary or a file..) and then read the data when the user presses the button.
import mysql.connector as mysql
....
mydb = mysql.connect(host = 'localhost',user = 'root',passwd = '****.',database = 'table_data')
data = {}
def store():
if dd_id.get() not in data:
data[dd_id.get()] = dd_owner.get()
print(data)
def upload():
cur = mydb.cursor()
for item in data.items():
sql = 'INSERT INTO table_data VALUES (%s,%s)'
params = (item[0],item[1])
cur.execute(sql,params)
mydb.commit()
print('Done')
....
# The store button
Button(window, text="Store data!",command=store).grid(column=0, row=3)
# The database button
Button(window, text="Send to database",command=upload).grid(column=0, row=4)
This will store the data in the database when the respective buttons are clicked, also duplicate entries or updatiion of entries will not be allowed.
Though your question is confusing. After looking at your discussion I understand that you want to send all data to the database only after the users have confirmed their choice.
In that case, you probably need a dictionary where you store both vehicle_id and owner {"vehicle_id": [], "owner": []} until the user clicks on the update database button. Once you have updated the database make sure to empty the dictionary so the previously selected items are not inserted into the database again.
Note: you would still need another button to be pressed several times to insert data into the dictionary. You can choose not to have the button by using the trace method of the control variable
Here is an example
from tkinter import *
import sqlite3
CREATE_QUERY = "CREATE TABLE IF NOT EXISTS vehicle(vehicle_id VARCHAR(5), owner VARCHAR(100));"
INSERT_QUERY = "INSERT INTO vehicle(vehicle_id, owner) VALUES(?, ?);"
SELECT_QUERY = "SELECT * FROM vehicle;"
sql_file = "sample.db"
id_dict = {"vehicle_id": [], "owner": []}
def create_data_base():
with sqlite3.connect(sql_file) as conn:
conn.execute(CREATE_QUERY)
conn.commit()
def insert_to_db():
global id_dict
with sqlite3.connect(sql_file) as conn:
for value in zip(*id_dict.values()):
conn.execute(INSERT_QUERY, value)
conn.commit()
id_dict = {"vehicle_id": [], "owner": []} # empty the list once you insert the data
display_data()
def display_data():
with sqlite3.connect(sql_file) as conn:
curr = conn.cursor()
curr.execute(SELECT_QUERY)
items = curr.fetchall()
print(items)
def add():
id_dict["vehicle_id"].append(dd_id.get())
id_dict["owner"].append(dd_owner.get())
print(id_dict)
owner = ['Spain', 'United Kingdom', 'Malaysia']
vehicleid = ['C161', 'C162']
window = Tk()
window.title("Running Python Script") # Create window
window.geometry('550x300') # Geo of the window
create_data_base()
##These are the option menus
dd_owner = StringVar(window)
dd_owner.set(owner[0]) # the first value
w = OptionMenu(window, dd_owner, *owner)
w.grid(row=1, column=1)
dd_id = StringVar(window)
dd_id.set(vehicleid[0])
w0 = OptionMenu(window, dd_id, *vehicleid)
w0.grid(row=0, column=1)
Button(window, text='Add', command=add).grid(column=1, row=3)
##The run button
run_list_button =Button(window, text="Send data of ID's to database!", command=insert_to_db)
run_list_button.grid(column=0, row=3)
##These are the titles
l1 = Label(window, text='Select Owner', width=15)
l1.grid(row=1, column=0)
l0 = Label(window, text='Select vehicle id:', width = 30)
l0.grid(row=0, column=0)
window.mainloop()
The above code will insert all the data from the dictionary to the database.
Please help. I am creating a little GUI dictionary and am trying to link the interface to a database. I can enter data (word and definition) into the database correctly but I cannot seem to look up words in the database so that the appropriate definition displays in the output box on my GUI.
Module 1 (main program):
from tkinter import *
import libraryentrySQL
import sqlite3
import os
def click():
entered_text = entry.get() #collect text from text entry box
output.delete(0.0,END) #clears text box - start clearing from 0.0 (from line 0) to END (after last character)
new_db = sqlite3.connect('dictionary.db')
c=new_db.cursor()
try:
definition = c.execute("SELECT definition FROM Dictionary WHERE word=%s", (entered_text))
except:
definition = "No word found in dictionary, try again!"
output.insert(END, definition) #this inserts the contents of variable 'definition' at the beginning (END) - because it was cleared before, END is the at the start
def clickentry(): #this function is run when the 2nd button (entry is pressed)
def definition_submitted(word, definition):
new_db = sqlite3.connect('dictionary.db')
c=new_db.cursor()
c.execute("INSERT INTO Dictionary VALUES (?, ?)", (word, definition))
new_db.commit()
new_db.close()
definition_window = libraryentrySQL.DefinitionWindow(window, definition_submitted) #this creates the object 'definition window' and passes to it 'the window variable'
#so that it can have a canvas
#and also passes the function 'definition_submitted' so that as the new word and definition are entered
#in the this object (second window) it can be passed into the function and the dictionary updated
window = Tk()
window.title("My Little Dictionary")
#Create the Label
Label(window, text="Enter the word you want defining:").grid(row=0, column=0, sticky=W)
#create entry box
entry=Entry(window, width=20, bg="light green")
entry.grid(row=1, column=0, sticky=W)
#create submit button
Button(window, text="Submit", width=5, command=click).grid(row=2, column=0, sticky=W)
#create second label
Label(window, text="\nDefinition").grid(row=3, column=0, sticky=W)
#create text box
output=Text(window, width=75, height=6, wrap=WORD, background="light green")
output.grid(row=4, column=0, sticky=W)
#create submit button to open enter new definition window
Button(window, text="Enter a New Definition", width=20, command=clickentry).grid(row=5, column=0, sticky=W)
#Create the Dictionary.db if not already present
if not os.path.isfile("dictionary.db"):
new_db = sqlite3.connect('dictionary.db')
c=new_db.cursor()
c.execute('''CREATE TABLE Dictionary
(word text,
definition text)''')
c.execute('''INSERT INTO Dictionary VALUES
('Algorithm', 'Step by step instructions to complete a task')''')
new_db.commit()
new_db.close()
window.mainloop()
module 2 (enter word and definition window):
from tkinter import *
class DefinitionWindow(Toplevel):
def __init__(self, root, click_callback):
Toplevel.__init__(self, root)
self.click_callback = click_callback
self.title("Library entry")
#Create the Label
Label(self, text="Enter the word you want to add:").grid(row=0, column=0, sticky=W)
#create entry box
self.word_entry=Entry(self, width=20, bg="light green")
self.word_entry.grid(row=1, column=0, sticky=W)
#create second label
Label(self, text="\nDefinition").grid(row=2, column=0, sticky=W)
#create entry box
self.definition_entry = Entry(self, width=50, bg="light green")
self.definition_entry.grid(row=3, column=0, sticky=W)
#create submit button
Button(self, text="Submit", width=5, command=self.clicked).grid(row=4, column=0, sticky=W)
def clicked(self):
self.click_callback(self.word_entry.get(), self.definition_entry.get()) #when this function is called (on submit button click) it takes the entered
#word and definition and assigns it to click_callback, which is an attribute of DefinitionWindow??
self.destroy() #after the word and definition are added to the call_back variable, the frame containing this instance of definition window is closed
What am I doing wrong? I know it is the "SELECT" SQL command which is not correct. Any help would be gratefully received. Thanks
This is not how SQL queries in Python work.
The execute method returns not a value but a cursor.
When nothing was found, no exception is raised, and the cursor is just empty.
Handling all exceptions blindy in the except block will hide any programming errors.
Furthermore, the parameters marker is not %s but ?.
Finally, a Python tuple with a single value must include a comma to differentiate it from a single expression:
c = new_db.cursor()
c.execute("SELECT definition FROM Dictionary WHERE word = ?", (entered_text,))
for row in c:
definition = row[0]
break
else:
definition = "No word found in dictionary, try again!"
output.insert(END, definition)
Hi I have a python search which works well and then I have a tkinter GUI which accepts a user input. The user input is then used to query the database using python. It matches records together depending on the input for example it would match blue to blue when I need it to be able to match blue to Blue etc. Does anybody know how to do this, here is an example of what I have already(N.B it is a made up scenario);
def Search():
global E1, E2, E3, E4, file
#Open the file in read mode
file = sqlite3.connect('H:\\matching.db')
#Welcome message
print ("Please type in the information required")
window = Tk()
window.title ("Search for matches")
def QuitSearch():
window.destroy()
#Create text that will be shown to the user
window.configure(bg="red")
Label(window, text="Please enter the colour of your hair").grid(row=0)
Label(window, text="Please enter the colour of your eyes").grid(row=1)
Label(window, text="Please enter your gender").grid(row=2)
Label(window, text="Please enter your shoe size").grid(row=3)
#Create where the user will input
E1= Entry(window)
E2= Entry(window)
E3= Entry(window)
E4= Entry(window)
#Assigning the input boxes to area on the screen
E1.grid(row=0, column=1)
E2.grid(row=1, column=1)
E3.grid(row=2, column=1)
E4.grid(row=3, column=1)
button = Button(window, text = "Submit information", command=Submit, fg="yellow", bg="black")
button.grid(row=3, column=2, padx = 5)
quitbutton = Button (window, text ="QUIT", command=QuitSearch, fg ="red")
quitbutton.grid(row=3, column=3, padx=5)
#The submit function allows the data inserted by the user in Search to be submitted and to search the database
def Submit():
global E1, E2, E3, E4, file
#Retaining user input
eyecolour = E1.get()
haircolour = E2.get()
gender = E3.get()
shoesize = E4.get()
#The search
cursor = file.execute ('''SELECT ID, forename, surname, FROM people
WHERE eyecolour =? and haircolour=? and gender=? and shoesize=? ''', (eyecolour, haircolour, gender, shoezize))
window=Tk()
def QuitOutputScreen():
window.destroy()
for row_number, row in enumerate(cursor):
Label(window, text ="ID = "+ str(row[0])).grid(row=1, column = row_number)
Label(window, text ="Forename = "+str(row[1])).grid(row=2, column = row_number)
Label(window, text ="Surname = "+(row[2])).grid(row=3, column = row_number)
Label(window, text ="Search complete ").grid(column=11)
quitbutton = Button (window, text ="QUIT", command=QuitOutputScreen, fg ="red")
quitbutton.grid(row=11, column=11, padx=5)
file.close()
This looks more like a question that concerns the DBMS (sqlite, in this case), rather than Python itself.
You can solve the problem using case-insensitive search query in sqlite. You can find some explanation at How to set Sqlite3 to be case insensitive when string comparing? .
Within you python code you can store and search using all lower or upper case, by using the string lower and upper function or you could use regular expressions and re.IGNORE_CASE to do your searching.
For DB queries you can either store everything in a fixed case or tell the DB engine to ignore case.
I am pretty new to Python, but for a team design project I need to create a code to input information into a Tkinter window that is connected to a mysql table and update that table accordingly. If the same ID is inputted again it should update the quantity +1 :
from Tkinter import*
import tkMessageBox
import tkFont
import mysql.connector
import time
def AddItem():
print "Added Item"
print "ID:" + ID.get()
print "Item Name:" + ItemName.get()
print "Price Per Item:" + PricePerItem.get()
print "Manufacturer:" + Manufacturer.get()
The s = INSERT INTO inventory... is throwing me for a loop, I can input the information into the Tkinter window but when I select the Add Item button, this error shows up:
ProgrammingError: Failed processing format-parameters; 'MySQLConverter' object has no attribute '_entry_to_mysql'
cnx = mysql.connector.connect(user='root',password='cj92cj',
database='INVENTORY', use_unicode=False)
s = "INSERT INTO inventory (ID, Manufacturer, ItemName, PricePerItem, Quantity) VALUES({},{},{},{},1) ON DUPLICATE KEY UPDATE Quantity= Quantity + 1, Manufacturer = VALUES(Manufacturer), ItemName = VALUES(ItemName), PricePerItem = VALUES(PricePerItem);".format(ID.get(),Manufacturer.get(),ItemName.get(),PricePerItem.get())
print ID.get()
print s
cursor = cnx.cursor()
cursor.execute(s, (ID, Manufacturer, ItemName, PricePerItem, Quantity))
cursor.close()
cnx.commit()
cnx.close()
def ClearEntries():
ItemName.delete(0,END)
PricePerItem.delete(0,END)
Manufacturer.delete(0,END)
I have been trying all sorts of things with "s" for hours and hours but I am having trouble figuring out the right syntax to use.
Below is the Tkinter Window code if that helps at all.
def InformationInput():
BigFont=tkFont.Font(family="Arial", size=14, weight="bold")
root.title("Enter Item Information")
root.geometry("1000x400")
root.bind("<Return>", lambda event: AddItem())
lbl1 = Label(root, text="ID:")
lbl2 = Label(root, text="Item Name:")
lbl3 = Label(root, text="Price Per Item:")
lbl4 = Label(root, text="Manufacturer:")
lbl9 = Label(root, text="Enter Item Information", height=3, fg="red", font=BigFont)
global ID, ItemName, PricePerItem, Manufacturer
ID = Entry(root, width=25, textvariable=ID)
ItemName = Entry(root, width=20, textvariable=ItemName)
PricePerItem = Entry(root, width=10, textvariable=PricePerItem)
Manufacturer = Entry(root, width=25, textvariable=Manufacturer)
button1 = Button(root, text="Add Item", command=AddItem, width=15)
button2 = Button(root, text="Clear Entries", command=ClearEntries, width=15)
button3 = Button(root, text="Exit", command=root.destroy, width=15)
lbl9.grid(column=2, row=1, columnspan=5)
lbl1.grid(column = 1, row = 4, sticky="nw")
ID.grid(column = 2, row = 4, sticky="nw")
lbl2.grid(column = 3, row = 4)
ItemName.grid(column = 4, row = 4)
lbl3.grid(column = 5, row = 4)
PricePerItem.grid(column = 6, row = 4, sticky="w")
lbl4.grid(column = 3, row = 10)
Manufacturer.grid(column = 4, row = 10)
button1.grid(column=3, row=15, sticky="e", pady=20)
button2.grid(column=4, row=15)
button3.grid(column=5, row=15, sticky="w")
root = Tk()
ID = IntVar()
ItemName = StringVar()
PricePerItem = IntVar()
Manufacturer = StringVar()
Quantity = IntVar()
InformationInput()
root.mainloop()
You have to use parameter marks in your query or your database driver, in this case MySQL Connector/Python, will through an error. Also, you have to pass values which can be converted. MySQLConverter does not know how to convert entry-objects, so it tells you it can't convert it (although it can be a bit more explicit).
Here is an example (simplified):
s = ("INSERT INTO inventory (ID, Manufacturer, ItemName, PricePerItem, Quantity) "
"VALUES (%s, %s, %s, %s, %s) ON DUP..")
cursor = cnx.cursor()
cursor.execute(s, (ID.get(), Manufacturer.get(), ItemName.get(),
PricePerItem.get(), Quantity.get()))
I took the liberty opening a bug report to improve the error message.
Other remark: I don't think you need to give the ID when inserting? Usually that is an AUTO_INCREMENT.