0

Here is my code

qry = " INSERT INTO transactions(transaction_id,listing_id) VALUES ('%s','%s')"
cursor.execute(qry, ('123', '456',))
db_con.commit()

I am getting error:

(1064, "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '123'',''456'')' at line 1")
2
  • I think that is supposed to be VALUES (%s, %s) Commented Mar 29, 2017 at 12:50
  • @khelwood That's correct. Commented Mar 29, 2017 at 12:52

2 Answers 2

3

You are using SQL parameters (yay!), and those already take care of proper quoting. You essentially double-quoted your values. Remove the quotes from the query:

qry = " INSERT INTO transactions(transaction_id,listing_id) VALUES (%s,%s)"
Sign up to request clarification or add additional context in comments.

Comments

0

Remove the double-quoted quotes from the query:

qry = " INSERT INTO transactions(transaction_id,listing_id) VALUES (%s,%s)"

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.