I am trying to insert data in a specific row using MYSQL in PYTHON.
I've tried the following code :
sql = "INSERT INTO board (pages) VALUES (%s) WHERE (ASIN) = '" + asinList[x] + "'"
val = (a)
myCurser.execute(sql, val)
However, I got this error :
"
mysql.connector.errors.ProgrammingError: 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '%s) WHERE (ASIN) = 'B07KWSRMK1'' "
how to solve it?
1 Answer 1
INSERT does not support WHERE clause with VALUES.
If you really want add a new rows then you should use INSERT.
sql = "INSERT INTO board (pages) VALUES (%s) '"
You may be looking to update an existing row. In this you should use UPDATE:
sql = "UPDATE board
SET pages = %s
WHERE ASIN = %s"