-3

I have been writing a small program for data entry and have been very frustrated because of a simple error. I am unable to figure it out. The Query is as follows:

query1= """
'INSERT INTO general_demographic 
(serial_number,district,mprpmu,ward,telephone,name,age,occupation,education)
VALUES(?,?,?,?,?,?,?,?,?)',
(str(SerialNumber.get()),
str(District.get()),
str(mprmmu.get()),
str(ward.get()),
str(telephone.get()),
str(name.get()),
str(age.get()),
str(occupation.get()),
str(c.get()))
"""

The error displayed is shown in the figure below: error

1
  • 2
    Please edit your question and paste the error message as text. Commented Sep 17, 2019 at 5:24

1 Answer 1

1

Your query is invalid but you are on the right track.

Instead of q = "'SQL (?) ', param_tuple" you should do more like this:

q = "SQL (?)"
valz = param_tuple
cursor.execute(q, valz) 

Actually the documentation of parameter substitution is quite good.

There are many examples here too.

Sign up to request clarification or add additional context in comments.

Comments