On Jul 13, 2009, at 8:31 AM, Roger Gammans wrote:
> pyodbc returns records of type pyodbc.Row which offers list/tuple
> style access
> rather than dict style.
>
> This means the test at line 358 of dCursorMixin.py (svn:r5293) takes
> the wrong branch and the code in the other branch won't work as
> pyodbc.Row
> hasn't a items() methods and the __getitems__ method requires an in
> parameter.
>
> Is there anyway we could force dCursorMixin to take the other branch
> in this by adding a flag ? Would that be acceptable?
We would need to be able to reference the type of the returned value;
I assume that this Row class is defined in the pyodbc module. This
would mean that *everyone* would have to have that file installed.
Is there anyway to cast these Row values into tuples or lists? Some
dbapi adapters give a choice of classes: MySQLdb, for example, has a
DictCursor class that returns the query results as dicts rather than
tuples. You might even be able to wrap pyodbc with your own code to
automatically do the conversion, and we could use the wrapped class
instead of pyodbc directly.
If not, I can switch the logic around in dCursorMixin to check for
dicts, and do the conversion on all results that are not dicts. This
would be more disruptive and require more testing, so if you can
handle this case at the pyodbc level, that would be much easier. If
not, though, I think we can make the switch in dCursorMixin without
too much trouble.
-- Ed Leafe
_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-users
Searchable Archives: http://leafe.com/archives/search/dabo-users
This message:
http://leafe.com/archives/byMID/[email protected]