Trying to run a MySQL script via Python and it keeps giving me errors. Here is my MySQL:
c.execute("""INSERT into DATA(checkup_date)
VALUES(%s) WHERE machine_name = %s
""", (date, machine))
What am I doing wrong?
ProgrammingError: (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 'WHERE machine_name = 'TL-D04'\nVALUES('2011-11-11')' at line 2")
INSERT INTO ... VALUES ... WHERE ...isn’t valid SQL. You can’t add aWHEREclause to anINSERTstatement.I’m guessing you want to update the
checkup_datecolumn for a row currently in theDATAtable, as opposed to inserting a new row. If that’s the case, tryinstead.