I'm a nube at the Python language and I'm having a hard time linking my Python GUI (in Tkinter) to a database. The layout is such that I want the end user to add Names to a database through an Entry widget. I tried to get the text to save to the database by using a variable, something like:
entr= Entry(frame1)
entr.grid(row=0, column=1)
var1=entr.get()
def save():
"""Save content in the entry box"""
con = mdb.connect(host="localhost", user="root", passwd="xxxxxx", db="xxxxxxx")
with con:
cur=con.cursor()
sql_update= "UPDATE Tests SET NAME='%s' WHERE id='%s'", (var1, id)
cur.execute(sql_update)
cur.close()
con.commit()
con.close()
this gives back the error message:
TypeError: query() argument 1 must be string or read-only buffer, not tuple
is there any way I can save data from the entry widget to the database without having to use var1 = raw_input("Name: ") somewhere else instead?
Thank you for your time! :)