Reputation: 21
I am new to tkinter and I am trying to connect python with MySQL. When I Try to insert the records via a new window in python I get the following error message
Exception in Tkinter callback
Traceback (most recent call last):
File "C:\Users\sapna\anaconda3\lib\tkinter\__init__.py", line 1705, in __call__
return self.func(*args)
File "C:\Users\sapna\Desktop\SAMARTH.py", line 141, in dynamic_data_entry
libcur.execute("INSERT INTO tcl VALUES(%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)" ,
(id1,name1,auth1,doi1,dor1,reiss,rname,Address,gen1,mil1))
File "C:\Users\sapna\anaconda3\lib\site-packages\mysql\connector\cursor_cext.py", line 248, in
execute
prepared = self._cnx.prepare_for_mysql(params)
File "C:\Users\sapna\anaconda3\lib\site-packages\mysql\connector\connection_cext.py", line 626, in
prepare_for_mysql
result = self._cmysql.convert_to_mysql(*params)
_mysql_connector.MySQLInterfaceError: Python type method cannot be converted
Here is the snip of my insert command.
def dynamic_data_entry():
bname.delete(0,END)
bid.delete(0,END)
author.delete(0,END)
DOI.delete(0,END)
DOR.delete(0,END)
RES.delete(0,END)
RNM.delete(0,END)
AD.delete(0,END)
mail.delete(0,END)
id1=ln.get()
name1=fn.get()
auth1=dn.get()
doi1=an.get()
dor1=gn.get()
rname=kn.get()
Address=pn.get
reiss=mn.get()
gen1=var.get()
mil1=ll.get()
libcur.execute("INSERT INTO tcl VALUES(%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)" ,
(id1,name1,auth1,doi1,dor1,reiss,rname,Address,gen1,mil1))
mydb.commit()
messagebox.showinfo("INSERT STATUS","RECORD HAS BEEN ADDED SUCCESSFULLY")
libcur.close()
The datatype that I have used is varchar() in Book_id,DOI,DOR and char() in others for MySQL. All the dataypes that I have used in Python are as follows
var=StringVar()
fn=StringVar()
yn=StringVar()
ln=StringVar()
dn=StringVar()
an=StringVar()
kn=StringVar()
gn=StringVar()
mn=StringVar()
pn=StringVar()
ll=StringVar()
Thanks in advance
Upvotes: 0
Views: 439
Reputation: 3504
Looks like you missed some parentheses in your assignment to Address
. Try Address=pn.get()
.
The error implies that you're passing a method rather than a value. This is consistent with Address=pn.get
, i.e. you're passing the pn.get
method rather than the return value of pn.get()
.
Upvotes: 1