title: How to use FetchAll in PyPyODBC Module for Python?
body: <p>I am trying to use <a href="https://code.google.com/p/pypyodbc/" rel="nofollow">PyPyODBC</a>, specifically a take on this <a href="https://code.google.com/p/pypyodbc/wiki/A_HelloWorld_sample_to_access_mssql_with_python" rel="nofollow">example</a>. However, I am not interested in creating a new table, I simply want to read the data (which resides in a database/table in SQL Server) and work with it inside of Python.</p>
  
  <p>The below code works fine with the exception of the following section (
  <code>for row in cur.fetchall():</code>).</p>
  
  <pre><code>from __future__ import print_function
  import pypyodbc
  from  pandas import *
  import pandas as pd
  con = pypyodbc.connect(driver = '{SQL Server}', server = 'WIN-SAV35R5AKCQ',database ='V2.0.6_X12_837I')
  
  cur = con.cursor()
  cur.execute('''SELECT * FROM TS837_2400;''')
  cur.commit()
  
  for d in cur.description: 
      print (d[0], end=" ")
  
  print('')
  
  for row in cur.fetchall():
      for field in row: 
          print (field, end=" ")
      print ('')
  
  cur.close()
  con.close()
  </code></pre>
  
  <p>However, I get this error.</p>
  
  <pre><code>---------------------------------------------------------------------------
  Error                                     Traceback (most recent call last)
  &lt;ipython-input-70-c08d5a03056a&gt; in &lt;module&gt;()
       14 print('')
       15 
  ---&gt; 16 for row in cur.fetchall():
       17     for field in row:
       18         print (field, end=" ")
  
  C:\Users\Administrator\Anaconda\lib\site-packages\pypyodbc.pyc in fetchall(self)
     1805         rows = []
     1806         while True:
  -&gt; 1807             row = self.fetchone()
     1808             if row is None:
     1809                 break
  
  C:\Users\Administrator\Anaconda\lib\site-packages\pypyodbc.pyc in fetchone(self)
     1900                 return None
     1901             else:
  -&gt; 1902                 check_success(self, ret)
     1903 
     1904     def __next__(self):
  
  C:\Users\Administrator\Anaconda\lib\site-packages\pypyodbc.pyc in check_success(ODBC_obj, ret)
      981     if ret not in (SQL_SUCCESS, SQL_SUCCESS_WITH_INFO, SQL_NO_DATA):
      982         if isinstance(ODBC_obj, Cursor):
  --&gt; 983             ctrl_err(SQL_HANDLE_STMT, ODBC_obj.stmt_h, ret, ODBC_obj.ansi)
      984         elif isinstance(ODBC_obj, Connection):
      985             ctrl_err(SQL_HANDLE_DBC, ODBC_obj.dbc_h, ret, ODBC_obj.ansi)
  
  C:\Users\Administrator\Anaconda\lib\site-packages\pypyodbc.pyc in ctrl_err(ht, h, val_ret, ansi)
      959                 raise OperationalError(state,err_text)
      960             elif state[:2] in (raw_s('IM'),raw_s('HY')):
  --&gt; 961                 raise Error(state,err_text)
      962             else:
      963                 raise DatabaseError(state,err_text)
  
  Error: (u'HY010', u'[HY010] [Microsoft][ODBC Driver Manager] Function sequence error')
  </code></pre>
  
  <p><strong>Question:</strong>
  <em>Ultimately</em>, I want to be able to investigate the data in Python.How can this be done?</p>
  
  <p>Thank you in advance.</p>