printing a int variable in a sqlite3 update query
<p>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 </p>

<pre><code>CREATE TABLE STATICIPS(
   ID INTEGER PRIMARY KEY   AUTOINCREMENT,
   IP           CHAR(50) NOT NULL,
   CITY           CHAR(50) NOT NULL,
   INCOMPLETE BOOL
, CMTSIP CHAR(50));
</code></pre>

<p>Here is the code</p>

<pre><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()`
</code></pre>

<p>The row[0] is the id in the db which is an int. I get this when i run the code:</p>

<pre><code> Traceback (most recent call last):
   File "getinc.py", line 16, in &lt;module&gt;
     conn.execute("UPDATE STATICIPS set INCOMPLETE = 0 where ID = " + row[0])
 TypeError: cannot concatenate 'str' and 'int' objects
</code></pre>

<p>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?</p>

<p>You need to leverage backticks.</p>

<pre><code>conn.execute("UPDATE STATICIPS set INCOMPLETE = 0 where ID = " + `row[0]`)
</code></pre>

python sqlite3