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

Michael Chermside mcherm at destiny.com
Wed Jan 16 10:47:04 EST 2002


> 
> 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()


Would something like this work for you?

    db.execute("myquery")
    result = convertToDict( db.fetchall() )

If so, convertToTuples shouldn't be too difficult to write...

-- Michael Chermside







More information about the Python-list mailing list