I'm creating a port scanner using python. When it finds an ip address I want it added to my "Devices" table. However I need to check to make sure this same IP is not already in my tables from an earlier scan. So I'm trying to run the following SQL in Python:
cursorObj.execute("INSERT INTO Devices VALUES('"+ipAddrFound+"', null, null, null, null) WHERE '"+ipAddrFound+"' NOT IN (Select ipAddr from Devices)")
However, when I run this I get the following error: sqlite3.OperationalError: near "WHERE": syntax error
I'm not understanding what the problem is. Any advice?
Thanks in advance.