Persistent db conn and fetchall() data with dict
Jarosław Zabiełło
webmaster at watchtowerDOTorg.pl
Sat Dec 28 22:01:54 EST 2002
On 28 Dec 2002 17:07:37 GMT, Gerhard Häring <gerhard.haering at gmx.de>
wrote:
>> Second, is it possible to get the result from the database with
>> dictionary (not pure tuple)? Eg.
>
>You can use the nonstandard methods dictfetchXXX(). Or you can use one
>of the database module independent dictionary wrappers. I believe Andy
>Dustman (MySQLdb author) has one on his homepage called dbObj.
I found the solution when I checked Python sources of MySQLdb. There
is the parameter 'cursorclass' which should be set as follows:
conn = MySQLdb.Connect(host='x',user='y',passwd='z',
db='mybase', compress=1,
cursorclass=MySQLdb.cursors.DictCursor)
--
JZ
More information about the Python-list
mailing list