I am trying to update a sqlite3 db once I get a true statement but I can't feed my variable, which is an int, to the query which is a str. Here is the database
CREATE TABLE STATICIPS(
ID INTEGER PRIMARY KEY AUTOINCREMENT,
IP CHAR(50) NOT NULL,
CITY CHAR(50) NOT NULL,
INCOMPLETE BOOL
, CMTSIP CHAR(50));
Here is the code
#!/usr/bin/python
import sqlite3
conn = sqlite3.connect('ipdb.sqlite')
cursor = conn.execute("SELECT ID, IP, CITY, INCOMPLETE, CMTSIP from STATICIPS WHERE CITY='LS'")
for row in cursor:
if (row[3] == 1):
print row[1]
searchfile = open("arp-ls.txt", "r")
for line in searchfile:
if row[1] + ' ' in line:
print line
conn.execute("UPDATE STATICIPS set INCOMPLETE = 0 where ID = " + row[0])
conn.commit
searchfile.close()`
The row[0] is the id in the db which is an int. I get this when i run the code:
Traceback (most recent call last):
File "getinc.py", line 16, in <module>
conn.execute("UPDATE STATICIPS set INCOMPLETE = 0 where ID = " + row[0])
TypeError: cannot concatenate 'str' and 'int' objects
So my question is how do I make it that row[0] prints correctly in my query so I can update the sqlite entry of this specific ID?