title: Function sequence error (0) (SQLFetch) - SQL, Pyodbc
body: <pre><code>for _item in file_list:
      for col in cursor.execute("select column1,column2 from tbl"):
          if _item[0]==col.column1:
              #I also tried using a different cursor, still doesn't work
              var1 = cursor.execute("select column2 from tbl where column1=?", _item[0])
              for i in var1: var2 = i[0]
              try:
                  cursor3.execute("insert into tbl(column2,column1,column3,column4) values (?,?,?,?)", (var1, _item[0],_item[1],_item[2]))
                  cursor3.commit() 
              except IOError as error:
                  print error
  </code></pre>
  
  <p>What i am trying to do is compare the values in a list and the ones from column1, if they match, get the value from column2 on the same row, then add a new line with the value from column2 but different values for the remaining ones.</p>
  
  <p>But unfortunately it doesen't work the way i did it, when running the code above python throws the error:</p>
  
  <pre><code>Error: ('HY010', '[HY010] [Microsoft][ODBC Driver Manager] Function sequence error (0) (SQLFetch)')
  </code></pre>
  
  <p>In line:</p>
  
  <pre><code>for columnrow in cursor.execute("select column1,column2 from tbl")
  </code></pre>