X

The leading edge of scripting languages and Oracle Database brought to you by the Data Access Development team

The New Python cx_Oracle 8.0 Interface for Oracle Database Brings Easier Configuration

Christopher Jones
Senior Principal Product Manager

cx_Oracle logo

cx_Oracle 8.0, the extremely popular Oracle Database interface for Python, is now Production on PyPI.

cx_Oracle is an open source package for the Python Database API specification with many additions to support advanced Oracle Database features.

 

This is a major release that adds to cx_Oracle's great Oracle Database support. You can hear me talk about some of the new cx_Oracle 8 features in the June 2020 Python Office Hours recording. The release notes contain all the changes and improvements.

Particular thanks go to Alex Henrie for a series of code cleanups and small fixes.

Main Changes

  • Python 3 support: In line with the upstream Python community farewelling Python 2, this release of cx_Oracle only installs in Python 3. (If you have Python 2 then installing cx_Oracle will give you the older cx_Oracle 7.3). See the installation instructions.

  • New method for locating the Oracle Client libraries: A new cx_Oracle.init_oracle_client() function can optionally be used to configure the Oracle Client. For example, the location of the Oracle Client libraries can be passed to it. This is most useful on Windows and macOS - particularly with recent macOS changes restricting library access. There are some limitations on Linux. The function can also be passed the configuration file directory where your optional files like tnsnames.ora are. See cx_Oracle 8 Initialization.

  • Default character sets are UTF-8: The default encoding and national language encoding are now UTF-8. Importantly the character set component of the NLS_LANG environment variable is now ignored. To change the encodings use the encoding and nencoding parameters when creating standalone connections or connection pools. See Character Sets and Globalization.

  • New Cursor.prefetchrows attribute for query fetch tuning: You can use Cursor.prefetchrows in conjunction with the existing Cursor.arraysize value to tune the number of round-trips taken to fetch rows after a query is executed. Round-trips between cx_Oracle and Oracle Database have a significant impact on performance and overall system scalability. I talk more about this in the Office Hours recording. Also review the cx_Oracle tuning documentation.

  • Database type constant improvements: The database type constant names were rationalized and some types added. Synonyms were created for backward compatibility. See the release notes for details and other type changes.

If you're new to cx_Oracle, look at our cx_Oracle Tutorial. Recently some great work from the Oracle LiveLabs team has made it immediately runnable in Oracle Cloud. Check out their Oracle Cloud instructions.

Installing or Upgrading cx_Oracle

Review the updated installation and configuration documentation, particuarly for macOS.

You can install or upgrade cx_Oracle by running:

python -m pip install cx_Oracle --upgrade

The pip options --force-reinstall, --proxy, and --user may be useful in some environments.

cx_Oracle References

Home page: oracle.github.io/python-cx_Oracle/index.html

Installation instructions: cx-oracle.readthedocs.io/en/latest/installation.html

Documentation: cx-oracle.readthedocs.io/en/latest/index.html

Release Notes: cx-oracle.readthedocs.io/en/latest/release_notes.html

Source Code Repository: github.com/oracle/python-cx_Oracle

Facebook group: www.facebook.com/groups/oraclescripting/

Questions: github.com/oracle/python-cx_Oracle/issues

Be the first to comment

Comments ( 0 )
Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.