[DB-SIG] fetchall() problem

M.-A. Lemburg mal@lemburg.com
Fri, 07 Apr 2000 23:07:54 +0200


Michael Guidry wrote:
> 
> Why doesn't this cursor.fetchall() work?
> 
> >>> import ODBC.Windows
> >>> conn = ODBC.Windows.Connect('FL_BS')
> >>> cursor = conn.cursor()
> >>> cursor.execute('SELECT AMTYP, AMLDS, AMDES FROM ATYMAST')
> >>> from pprint import pprint
> >>> pprint(cursor.description)
> (('AMTYP', -9, None, None, 2, 0, 1),
>  ('AMLDS', -9, None, None, 30, 0, 1),
>  ('AMDES', -9, None, None, 12, 0, 1))
> >>> data = cursor.fetchall()
> Traceback (innermost last):
>   File "<interactive input>", line 1, in ?
> InterfaceError: SQL type (code -9) not implemented

Because SQL type -9 is Unicode and there currently is no Unicode
support in mxODBC. Try converting the columns to string using
SQL functions and then retry the fetch.

> >>> dir(cursor)
> ['arraysize', 'close', 'colcount', 'columnprivileges', 'columns',
> 'datetimeformat', 'description', 'execute', 'fetchall', 'fetchmany',
> 'fetchone', 'foreignkeys', 'getcursorname', 'gettypeinfo', 'primarykeys',
> 'procedurecolumns', 'procedures', 'rowcount', 'setcursorname',
> 'setinputsizes', 'setoutputsizes', 'specialcolumns', 'statistics',
> 'tableprivileges', 'tables']


-- 
Marc-Andre Lemburg
______________________________________________________________________
Business:                                      http://www.lemburg.com/
Python Pages:                           http://www.lemburg.com/python/