cx_Oracle is an open source package that covers the Python Database API specification with many additions to support Oracle advanced features.
Top Feature: Cursor.executemany() support for OUT bind variables in DML RETURNING statements.
This release contains a number of bug fixes and useful improvements. For the full list, see the Release Notes, but I wanted to highlight a few features:
Support for binding integers and floats as cx_Oracle.NATIVE_FLOAT.
Support for true heterogeneous session pools that use different username/password combinations for each session acquired from the pool.
All cx_Oracle exceptions raised by cx_Oracle now produce a cx_Oracle._Error object.
Support for getting the OUT values of bind variables bound to a DML RETURNING statement when calling Cursor.executemany(). For technical reasons, this requires setting a new attribute in cx_Oracle.__future__. As an example:
cx_Oracle.__future__.dml_ret_array_val = True data = [, , ] childIdVar = cursor.var(int, arraysize = len(data)) cursor.setinputsizes(None, childIdVar) cursor.executemany(""" delete from ChildTable where ParentId = :1 returning ChildId into :2""", data) for ix, inputRow in enumerate(data): print("Child ids deleted for parent id", inputRow, "are", childIdVar.getvalue(ix))
Want to know what this displays? Stay tuned to this blog site for an upcoming post on using executemany() in cx_Oracle!
Home page: oracle.github.io/python-cx_Oracle/index.html
Installation instructions: cx-oracle.readthedocs.io/en/latest/installation.html
Release Notes: cx-oracle.readthedocs.io/en/latest/releasenotes.html
Source Code Repository: github.com/oracle/python-cx_Oracle