I'm getting an error here:
"mysql.connector.errors.ProgrammingError: 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'WHERE id=' at line 1"
The code for tkinter is as below:enter code here
def new_window():
m2=Tk()
def inventory():
for i in table2.get_children():
table2.delete(i)
mydb = mysql.connector.Connect(host="127.0.0.1",
port="3306",
user="root",
auth_plugin="Native MYSQL Authentication",
database="bookstore")
cursor_1 = mydb.cursor()
cursor_1.execute("select * from inventory")
rows = cursor_1.fetchall()
if rows:
for i in rows:
table2.insert('', END, values=i)
mydb.close()
def update_inventory():
mydb = mysql.connector.Connect(host="127.0.0.1",
port="3306",
user="root",
auth_plugin="Native MYSQL Authentication",
database="bookstore")
cursor_1 = mydb.cursor()
cursor_1.execute(f"UPDATE inventory set purchased={var8.get()} WHERE id={var7.get()}")
mydb.commit()
inventory()
messagebox.showinfo("Update", "Inventory has been updated!")
mydb.close()
#Heading label:
label=Label(m2,bg="Dark Khaki",text="Welcome To Inventory",font=("Times New Roman",30))
label.pack(side=TOP,fill=X)
frame1= Frame(m2, bg="Pale Goldenrod") #making a frame below heading
frame1.place(x=150, y=120, width=900, height=520)
button=Button(frame1,bg="Olive Drab",fg="White",font=("Times New Roman",14),width=5,height=22,bd=5,
text="S\nH\nO\nW\n\nI\nN\nV\nE\nN\nT\nO\nR\nY\n\nD\nE\nT\nA\nI\nL\nS",command=inventory)
button.grid(row=0,column=0,padx=50,pady=15)
another_frame=Frame(m2,bg="Pale Goldenrod")
another_frame.place(x=1100,y=120,width=200,height=350)
label=Label(m2,text="Today's Record",bg="grey19",fg="White",font=("Times New Roman",15))
label.place(x=1130,y=90)
l = Label(another_frame, text="Book ID",font=("Times New Roman",10), fg="White", bg="Gray", width=15, height=2)
l.grid(row=0, column=0, padx=40, pady=10)
e = Entry(another_frame, textvariable=var7, width=15, bg="White", fg="black", bd=5)
e.grid(row=1, column=0, padx=40,pady=10)
label1=Label(another_frame,text="Purchased",font=("Times New Roman",10),bg="Gray",fg="White",width=15,height=2)
label1.grid(row=2,column=0,padx=40,pady=10)
entry1=Entry(another_frame,textvariable=var8,bg="White",width=15,bd=5)
entry1.grid(row=3,column=0,padx=40,pady=10)
label2 = Label(another_frame, text="Borrowed",font=("Times New Roman",10), bg="Gray", fg="White", width=15, height=2)
label2.grid(row=4, column=0,padx=40, pady=10)
entry2 = Entry(another_frame, textvariable=var9, bg="White", width=15, bd=5)
entry2.grid(row=5, column=0, padx=40, pady=10)
update_btn_frame=Frame(m2)
update_btn_frame.place(x=500,y=570,width=175,height=50)
update_btn=Button(update_btn_frame,text="Update Inventory",font=("Times New Roman",15),bg="Medium Purple1",fg="Black",
width=25,height=2,bd=5,command=update_inventory)
update_btn.pack()