title: How to update row while in " for row in cursor.execute" loop pyodbc?
body: <p>Here is my code. I just want to update the current row while i am in the loop.</p>
  
  <pre><code>import pyodbc
  import requests, re, time
  from datetime import datetime
  
  proxy = { 'http': '77.237.228.203:1212'}
  user_agent = {'user-agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:32.0) Gecko/20100101 Firefox/32.0'}
  
  cnxn = pyodbc.connect('DRIVER={SQL Server};SERVER=&lt;servername&gt;;DATABASE=&lt;databasename&gt;;UID=&lt;username&gt;;PWD=&lt;password&gt;');
  cursor = cnxn.cursor()
  
  for rows in cursor.execute("""SELECT DocumentLink,TrackingNumber,DocumentClass,TXDocNumberSequence
                               FROM TXWellDocumentList
                               WHERE Downloaded='NO'"""):
      row = cursor.fetchone()
      url = str(row.DocumentLink)
      print url
  
      if row[0]:
  
          fileName = 'TX_'+str(row.TrackingNumber)+'_'+str(row.DocumentClass)+'_'+str(row.TXDocNumberSequence)
          print fileName
  
          content = {}
          r = requests.get(url, proxies=proxy,headers=user_agent)
          content = r.headers; 
          extType= content['content-type']
          ext = re.search(r'/(\w+)',extType).group(1);print ext;
          size = content['content-length']*.001
  
          if ext=='pdf':
              with open(fileName+'.'+ext, "wb") as datum:
                  datum.write(r.content)
              datum.close()
          else:
              with open(fileName+'.'+'tif', "wb") as datum:
                  datum.write(r.content)
              datum.close()
          dt = str(datetime.now()).strip(',')
          #update table
          update = """UPDATE TXWellDocumentList
          SET Downloaded=?, DownLoadedAs=?,DownLoadedWhen=?,DownLoadedSizeKB=?
          WHERE TXDocNumberSequence=?"""
  
          result = cursor.execute(update,'Yes', fileName+'.'+ext, dt, size,uniqueID )
      time.sleep(5)
      else:
          print "empty"
  </code></pre>
  
  <p>In the update table section i want to update the current row with new variables. Unfortunately this doesn't work.</p>
  
  <pre><code>row.DownLoadedAs = fileName
  row.DownLoadedWhen = dt
  row.DownLoadedSizeKB = size
  cnxn.commit()
  </code></pre>
  
  <p>Can i update this row from here or do i have to update with a long update cursor execution outside of the loop?</p>
  
  <p>When i do:</p>
  
  <pre><code>update = """UPDATE TXWellDocumentList
                      SET Downloaded=?, DownLoadedAs=?,DownLoadedWhen=?,DownLoadedSizeKB=?
                      WHERE TXDocNumberSequence=?"""
  
  result = cursor.execute(update,'Yes', fileName+'.'+ext, dt, size,uniqueID )
  </code></pre>
  
  <p>I get an error saying: 
  ProgrammingError: No results.  Previous SQL was not a query.</p>