cx_Oracle is the python programming's oracle database module. It needs oracle client to connect to oracle database. It follows the python's database API specifications. I shared a very small code snippet below about how to use oracle plsql ref cursor type using the cx_Oracle.
#!/usr/bin/python # -*- coding: utf-8 -*- import cx_Oracle as cxo conn=cxo.connect('<username>/<password>@<host>/<database sid>') cursor=conn.cursor() temp_cursor=conn.cursor() cursor.execute(''' DECLARE TYPE cursor_type IS REF CURSOR; PROCEDURE myproc(mycursor OUT cursor_type) IS BEGIN OPEN mycursor FOR SELECT * FROM <any table or view>; END; BEGIN myproc(:mycursor); END;''',{"mycursor": temp_cursor}) for row in temp_cursor: print row cursor.close() temp_cursor.close() conn.close()
Discussion