I have an update query which is returning an error, this is the code:
self.cur.execute("UPDATE Trainers SET Name=?, DOB=?, Gender=?",(Name, DOB, Gender))
This is the error:
sqlite3.OperationalError: near ",": syntax error
-
Have a look, maybe it will help you: sqlite3.OperationalError: near "?": syntax error OR Python sqlite3 OperationalError: near "?": syntax errorValerica– Valerica2018年02月27日 11:12:26 +00:00Commented Feb 27, 2018 at 11:12
-
HI, I edited the code as in these questions and it is still returning the same error.Daniel Patrick– Daniel Patrick2018年02月27日 11:15:47 +00:00Commented Feb 27, 2018 at 11:15
1 Answer 1
Try to use curly braces it will help you.
self.cur.execute("UPDATE Trainers SET Name={}, DOB={}, Gender={}",(Name, DOB, Gender))
answered Feb 27, 2018 at 11:15
Hasnain Bukhari
4682 gold badges6 silver badges23 bronze badges
Sign up to request clarification or add additional context in comments.
2 Comments
Daniel Patrick
Hi, that returns the error
IndexError: tuple index out of rangHasnain Bukhari
If are getting this issue. It should not throw any error. you can use alternative syntax as well. self.cur.execute("UPDATE Trainers SET Name=%s, DOB=%s, Gender=%s",(Name, DOB, Gender)) These might be the alternative solution
default