mysql-python with cursor that returns either dicts or tuples?

Steve Holden sholden at
Wed Jan 16 17:55:28 CET 2002

"Gabriel Ambuehl" <gabriel_ambuehl at> wrote in message
news:mailman.1011193358.24672.python-list at
> Hello,
> I'm wondering whether there is any solution to have mysql-python use
> a
> Cursor class that can return either a dictionary or a tuple since I'd
> like to use one single cursor instance in my app but in some places a
> tuple is better (for performance reasons) whereas in others, a
> dictionary is what's needed.
> So something like:
> db.execute("myquery")
> db.fetchallDict()
> db.execute("mybigquery")
> db.fetchallTuple()
Both Michael and Alex have given useful advice. Might I just play Devil's
advocate and ask WHY you feel the need for just a single cursor? As long as
they are created from the same connection they should, I believe, share all
important resources and be jointly committed. I wondered what your need for
a single cursor is based on.

Consulting, training, speaking:
Python Web Programming:

More information about the Python-list mailing list