[cx-oracle-users] Tuple of Dictionaries query results
Brought to you by:
atuining
From: Tom H. <tom...@sc...> - 2006-04-18 15:25:23
|
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 = DictCursor ... curs = conn.cursor(cursortype) result = curs.execute("%s" % (sql, )) return curs.fetchall() ------------------- And in Postgres I do it like this: ----------------- import pg ... result = 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 |