Reputation:
I'm trying to use the following code
cursor.execute("INSERT INTO players (wins) VALUES (?) WHERE username = ?", (wins[3], players))
and am getting the following error
cursor.execute("INSERT INTO players (wins) VALUES (?) WHERE username = ?", (wins[3], players))
sqlite3.OperationalError: near "WHERE": syntax error
My table has two columns, username and wins. Wins[3] is the list value that stores the win integer, and players is the username.
Upvotes: 0
Views: 551
Reputation: 1125078
There is no WHERE
part in an INSERT
statement; INSERT
only adds a new row, so there is nothing to limit what existing rows the statement applies to here.
You want to use an UPDATE
instead:
cursor.execute("UPDATE players SET wins=? WHERE username = ?", (wins[3], players))
Upvotes: 2