[Twisted-Python] mapped resultsets for adbapi: "runQueryMapped"
James Y Knight
foom at fuhm.net
Fri Jun 4 11:22:10 EDT 2004
I'll note that you don't actually have to change adbapi in order to do
this. See the "runInteraction" method call.
You would do something like:
def mapQuery(curs, *args, **kwargs):
result = curs.fetchall()
columns = [d for d in curs.description]
return [dict(zip(columns, r)) for r in result]
On Jun 4, 2004, at 4:29 AM, Federico Di Gregorio wrote:
> Lì venerdì, 2004/06/04 alle 02:33, -0400, Stephen Waterbury ha scritto:
>> I don't know whether this is of interest to anyone else, but
>> I needed it for my stuff and I was hoping it might be suitable for
>> inclusion in adbapi: it defines a new adbapi.ConnectionPool method
>> called 'runQueryMapped' (and corresponding '_runQueryMapped') whose
>> return value is a list of dicts that map column names to values
>> (rather than the list of lists of values that runQuery returns).
> i think it is a usefull addition.
> Federico Di Gregorio
> Debian GNU/Linux Developer
> fog at debian.org
> INIT.D Developer
> fog at initd.org
> We are all dust, Saqi, so play the lute
> We are all wind, Saqi, so bring wine. -- Omar
> Twisted-Python mailing list
> Twisted-Python at twistedmatrix.com
More information about the Twisted-Python