RE: [cx-oracle-users] Tuple of Dictionaries query results
Brought to you by:
atuining
From: Hancock, D. \(DHANCOCK\) <DHA...@ar...> - 2006-04-18 15:42:16
|
I think that the module dtuple.py (written by Greg Stein) will do what = you want (it's very flexible in how you can refer to the query results). = Actually, I'm not 100% sure that you'll get the tuple of dictionaries, = but that would be a very simple wrapper. =20 http://www.lyra.org/greg/python/dtuple.py =20 Cheers! -- David Hancock ________________________________ From: cx-...@li... on behalf of Tom = Haddon Sent: Tue 4/18/2006 11:23 AM To: cx-...@li... Subject: [cx-oracle-users] Tuple of Dictionaries query results Hi Folks, I was wondering if anyone knows if there's a way to grab the results of an Oracle query into a tuple of dictionaries (one for each row with the key as the column name and the value as the value of the column)? In mysql I do this as below: ---------------- import MySQLdb from MySQLdb.cursors import DictCursor cursortype =3D DictCursor ... curs =3D conn.cursor(cursortype) result =3D curs.execute("%s" % (sql, )) return curs.fetchall() ------------------- And in Postgres I do it like this: ----------------- import pg ... result =3D conn.query("%s" % (sql, )) return result.dictresult() ------------------ I can't seem to see if there are any cursor types as with MySQLdb module, or a dictresult query return method as with the pg module. Basically this then allows me to reference the data as follows: for row in TupleOfDicts(): print "%s %s" % (row['column1'], row['column2']) Any help appreciated. Thanks, Tom -- Tom Haddon Systems Engineer 198 High Holborn London, WC1V 7BD T +44 (0) 20 7959 0630 www.scansafe.com ScanSafe - Pure Internet ------------------------------------------------------- This SF.Net email is sponsored by xPML, a groundbreaking scripting = language that extends applications into web and mobile media. Attend the live = webcast and join the prime developer group breaking into this new coding = territory! http://sel.as-us.falkag.net/sel?cmd=3Dlnk&kid=3D110944&bid=3D241720&dat=3D= 121642 _______________________________________________ cx-oracle-users mailing list cx-...@li... https://lists.sourceforge.net/lists/listinfo/cx-oracle-users |