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

"Einar S. Idsø" einar.twisted at norsk-esport.no
Sat Feb 24 19:27:12 EST 2007


L. Daniel Burr wrote:
> This is very easy to do, because adbapi.ConnectionPool will pass on
> connection-specific parameters to the underlying DBAPI module.
> 
> Example (untested):
>  (...)
> pool = db.ConnectionPool(
>     MySQLdb,
>     host="my.host.com",
>     port=1234,
>     cursorclass=MySQLdb.cursors.DictCursor
> )

Wow, thank you! Now /there/ is the proper way of returning a dict :) I
just can't believe it was that easy...

> The key thing to understand in this case is that adbapi is just a simple
> wrapper around a given DBAPI module, so if you know how to configure
> MySQLdb, then configuring adbapi.ConnectionPool is very similar.  Just
> pass the same keyword args to ConnectionPool, that you would pass to
> MySQLdb, and you're good to go.
> 
> 
> Hope this helps,
> 
> L. Daniel Burr

It was just the help I needed: An example to solve my problem, and a
much-needed explanation of adbapi. Perfect!

Thank you so much,
Einar




More information about the Twisted-Python mailing list