[Twisted-Python] How to properly return a dict from adbapi

L. Daniel Burr ldanielburr at mac.com
Tue Feb 20 05:34:48 MST 2007


On Tue, 20 Feb 2007 05:40:17 -0600, Phil Mayers <p.mayers at imperial.ac.uk>  
wrote:

> Einar S. Idsø wrote:
>> Itamar Shtull-Trauring wrote:
>>> Some database adapters will return objects that act like dictionaries,
>>> or have an extra method that does so. adabpi itself doesn't really
>>> provide any extra infrastructure for doing so since it's intended as a
>>> thin layer wrapping db-api.
>>  So in other words: The technique I am using is okay? Or should I be
>
> yes
>
>> using one of the other adapters? If so, would you mind pointing me to
>
> only if it provides dictfetchall() support
>
>> some of my options as I haven't been able to find any simple
>> alternatives to adbapi?
>
> You misunderstand - you have to use adbapi. The choice is which python  
> DB-API adapter the adbapi connection will "wrap".
>
> I'm afraid I don't use MySQL so I don't know if any have dict* support.
>

The MySQLdb adapter has a DictCursor, which subclasses the usual dbapi
cursor, and should meet the original poster's needs.

Another solution is to use something like db_row (Google for it).

Hope this helps,

L. Daniel Burr




More information about the Twisted-Python mailing list