Skip to Main Content

DevOps, CI/CD and Automation

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

cx_Oracle cursor - return named tuple

jstem1177Jan 21 2014 — edited Jan 21 2014

Hello All,

I'm having trouble figuring a way to convert the row returned from a basic execute statement into a named tuple/Dictionary.

The idea, is to be able to access each field via row['column_name']. I'm currently looking at creating a factory, but still a complete noob to python and cx_Oracle.

cur.execute(""SELECT * FROM V$INSTANCE""")

#print 'Query Executed..'

row = cur.fetchone()

#print 'Cursor Loaded.'

#print result[0], result[1]

list = {}

list['host_name'] = row['host_name']

print row['host_name']

Thanks in advance for your assistance.

Jan S.

This post has been answered by jstem1177 on Jan 21 2014
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Feb 18 2014
Added on Jan 21 2014
1 comment
7,401 views