python update cursor issue - error with %s symbol?
<p>this is probably a <em>really</em> stupid problem, but i've been looking at it for a few hours and cannot work it out.</p>

<p>So here goes:</p>

<pre><code> def updateEntryAsYoutubeProcessing(self,conn,id):
            cursor = conn.cursor()
            try:
                    numberAffected = cursor.execute("update new_files set is_youtube = 1 where id=%s",(id))
                    conn.commit()
            except MySQLdb.IntegrityError,e:
                    logging.warn("update failed with error \n\t%d:%s",e.args[0],e.args[1])
                    raise
            finally:
                    cursor.close()
</code></pre>

<p>this code <em>always</em> results in an error:</p>

<pre><code>  Traceback (most recent call last):
  File "mydaemon.py", line 28, in loopForEachFileInDirectory
    self.updateEntryAsYoutubeProcessing(conn,id)
  File "mydaemon.py", line 80, in updateEntryAsYoutubeProcessing
    numberAffected = cursor.execute("update new_files set is_youtube = 1 where id=%s",(id))
  File "/usr/lib/pymodules/python2.6/MySQLdb/cursors.py", line 166, in execute
    self.errorhandler(self, exc, value)
  File "/usr/lib/pymodules/python2.6/MySQLdb/connections.py", line 35, in defaulterrorhandler
    raise errorclass, errorvalue
  ProgrammingError: (1064, "You have an error in your SQL syntax; check the manual that   corresponds to your MySQL server version for the right syntax to use near '%s' at line 1")
</code></pre>

<p>I've tried my code with double quotes, triple double quotes, the sql defined as a variable and placed in the execute, everything i can think of.</p>

<p>What am i missing?</p>

<p>I've tried the sql on the database, and it works fine (substituting the %s with a value, obvi).</p>

<p>EDIT:
ok, so the problem i was <em>really</em> having was that id was None. The next problem i was having was that, as noted in the answers (thanks!), I needed to make the <code>(id)</code> into <code>(id,)</code>, because tuples.</p>

<p>Now that it is a tuple, I get a "Nonetype" error thrown. Thanks all, obviously i'm fixing my code to use typles (and also to not inject None into the db)</p>
