Re: [cx-oracle-users] Tuple of Dictionaries query results
Brought to you by:
atuining
From: <wa...@li...> - 2006-04-18 15:42:03
|
Anthony Tuininga wrote: > If you want to do this you should be able to do it as follows. Note > that this will reduce performance quite dramatically but if you are > only dealing with a handful of rows the additional clarity might be > worthwhile. > > class Cursor(cx_Oracle.Cursor): > > def __TransformToDict(self, row): > return dict([(info[0], value) for info, value in > zip(cursor.description, row)]) > > def fetchone(self): > row = super(Cursor, self).fetchone() > return self.__TransformToDict(row) > > etc. (for fetchall() and fetchmany()) Or you could use ll-orasql (http://www.livinglogic.de/Python/orasql/) which does exactly that (and makes the fields available as attributes too). Bye, Walter Dörwald |