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

Steve Holden sholden at holdenweb.com
Wed Jan 16 11:55:28 EST 2002


"Gabriel Ambuehl" <gabriel_ambuehl at buz.ch> wrote in message
news:mailman.1011193358.24672.python-list at python.org...
> -----BEGIN PGP SIGNED MESSAGE-----
>
> 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.

regards
 Steve
--
Consulting, training, speaking: http://www.holdenweb.com/
Python Web Programming: http://pydish.holdenweb.com/pwp/








More information about the Python-list mailing list