Persistent db conn and fetchall() data with dict
Jarosław Zabiełło
webmaster at watchtowerDOTorg.pl
Sat Dec 28 05:45:21 EST 2002
I have two questions.
First. Is there a possibillity for *persistent* connection to MySQL
using MySQLdb module? Does it mean, I do not need to close db
connection? What about opened cursor? Should I close it, or I can
leave it as it is?
Second, is it possible to get the result from the database with
dictionary (not pure tuple)? Eg.
rows = cursor.fetchall()
for row in rows:
print row['MyField1'], row['MyField2']
For now, I must remember the order of all fields of my query. It is
unconvienent to use:
print row[0], row[1]
--
JZ
More information about the Python-list
mailing list