webminal.org
webminal.org

Reputation: 47196

sqlite python insert with where condition

from this post sqlite python insert I learned inserting into tables but now I need to use where something like

cursor.execute("insert into table1(id) values (?) where ip=? and address=?",(id,),(ip,),(addr,));

Upvotes: 2

Views: 2008

Answers (2)

Max Shawabkeh
Max Shawabkeh

Reputation: 38603

You can't use a WHERE clause in an INSERT. If you want to specify the values for particular fields to insert, put them in the values clause:

cursor.execute("INSERT INTO table1(id, ip, address) VALUES (?, ?, ?)", (id, ip, addr))

Upvotes: 0

amphetamachine
amphetamachine

Reputation: 30595

INSERT does not have a WHERE clause. I think you mean UPDATE.

Upvotes: 4

Related Questions