0

Hello I'm trying to delete a row with this code:

sql = "DELETE FROM produto WHERE prod_nu = %s"
data = input("""
    Type Data.
""")
cursor.execute(sql,(data))

The table produto does contain prod_nu and has an entry with prod_nu = 1. Which I'm trying to delete. The error says that I should check MySQL Manual about the syntax near "%s" at line 1.

Thanks for any assistance.

1
  • This should give a syntax error. Oct 22, 2013 at 20:18

1 Answer 1

0

Try putting a comma after data

cursor.execute(sql,(data,))

This will make it a tuple with one item. It currently will convert your string into a list of characters.

Or I think you can just remove the parentheses around data. Its been a while since I've done it that way, so I can't remember.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.