What’s New

cx_Oracle 6.0

This document contains a summary of the changes in cx_Oracle 6 compared to cx_Oracle 5.3. cx_Oracle 6.0 was released on August 14, 2017. See the release notes for complete details.


  • Has been re-implemented to use the new ODPI-C abstraction layer for Oracle Database. The cx_Oracle API is unchanged. The cx_Oracle design, build and linking process has improved because of ODPI-C.
  • Now has Python Wheels available for install. This is made possible by the ODPI-C architecture. Windows installers and Linux RPMs are no longer produced since PyPI no longer supports them.
  • Has less code in Python’s Global Interpreter Lock, giving better scalability.
  • Added support for universal rowids.
  • Added support for DML returning of multiple rows.
  • Now associates LOB locators to LOB objects so they are not overwritten on database round trips.

Installation Changes

  • On Linux, cx_Oracle 6 no longer uses instant client RPMs automatically. You must set LD_LIBRARY_PATH or use ldconfig to locate the Oracle Client library.
  • On platforms other than Windows, if ORACLE_HOME is set (in a database or full client installation), remove requirement to set LD_LIBRARY_PATH in order to locate the Oracle Client library (issue 20).

Connection Management Enhancements

  • Prevent closing the connection when there are any open statements or LOBs and add new error “DPI-1054: connection cannot be closed when open statements or LOBs exist” when this situation is detected; this is needed to prevent crashes under certain conditions when statements or LOBs are being acted upon while at the same time (in another thread) a connection is being closed; it also prevents leaks of statements and LOBs when a connection is returned to a session pool.
  • Added attribute SessionPool.stmtcachesize to support getting and setting the default statement cache size for connections in the pool.
  • Added attribute Connection.dbop to support setting the database operation that is to be monitored.
  • Added attribute Connection.handle to facilitate testing the creation of a connection using a OCI service context handle.
  • Added parameters tag and matchanytag to the cx_Oracle.connect() and SessionPool.acquire() methods and added parameters tag and retag to the SessionPool.release() method in order to support session tagging.
  • Added parameter edition to the cx_Oracle.SessionPool() method.
  • Added parameters region, sharding_key and super_sharding_key to the cx_Oracle.makedsn() method to support connecting to a sharded database (new in Oracle Database 12.2).
  • Removed requirement that encoding and nencoding both be specified when creating a connection or session pool. The missing value is set to its default value if one of the values is set and the other is not (issue 36).
  • Permit use of both string and unicode for Python 2.7 for creating session pools and for changing passwords (issue 23).

Data Type and Data Handling Enhancements

  • Added attributes Variable.actualElements and Variable.values to variables.
  • Added support for smallint and float data types in Oracle objects, as requested (issue 4).
  • Added support for getting/setting attributes of objects or element values in collections that contain LOBs, BINARY_FLOAT values, BINARY_DOUBLE values and NCHAR and NVARCHAR2 values. The error message for any types that are not supported has been improved as well.
  • An exception is no longer raised when a collection is empty for methods Object.first() and Object.last(). Instead, the value None is returned to be consistent with the methods Object.next() and Object.prev().
  • Removed requirement for specifying a maximum size when fetching LONG or LONG raw columns. This also allows CLOB, NCLOB, BLOB and BFILE columns to be fetched as strings or bytes without needing to specify a maximum size. The method Cursor.setoutputsize() no longer does anything, since ODPI-C automatically manages buffer sizes of LONG and LONG RAW columns.
  • Enable temporary LOB caching in order to avoid disk I/O as suggested (issue 10).

Error Handling Enhancements

  • Provide improved error message when OCI environment cannot be created, such as when the oraaccess.xml file cannot be processed properly.
  • Define exception classes on the connection object in addition to at module scope in order to simplify error handling in multi-connection environments, as specified in the Python DB API.

Test Enhancements

  • Reworked test suite and samples so that they are independent of each other and so that the SQL scripts used to create/drop schemas are easily adjusted to use different schema names, if desired.
  • Updated DB API test suite stub to support Python 3.