[Twisted-Python] mapped resultsets for adbapi: "runQueryMapped"
Stephen Waterbury
golux at comcast.net
Fri Jun 4 12:01:17 EDT 2004
James Y Knight wrote:
> 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):
> curs.execute(*args, **kwargs)
> result = curs.fetchall()
> columns = [d[0] for d in curs.description]
> return [dict(zip(columns, r)) for r in result]
>
> then:
> dbpool.runInteraction(mapQuery, ...)
Interesting -- I wasn't aware of that usage of runInteraction.
Still, that means that anyone who wants to get a mapped query
result from adpapi will have to have that construction in
their code. I prefer to have it in adbapi, myself, since
it is a relatively low-level pattern.
Steve
More information about the Twisted-Python
mailing list