X

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

Faster JSON with Python cx_Oracle 8.1 and Oracle Database 21's new OSON storage format

Christopher Jones
Senior Principal Product Manager

cx_Oracle logo

 

 

cx_Oracle 8.1, 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.

 

 

The top features in cx_Oracle 8.1 are:

  • Support for Python 3.9 was added.

    Also support Python 3.5 was removed, since it has reached end-of-life.

  • Enhanced JSON functionality to support Oracle Database 21's native OSON storage format for JSON. A new cx_Oracle type cx_Oracle.DB_TYPE_JSON was added.

    Python dicts and lists can now be bound directly when using the new storage type:

    sql = "insert into customers values (:1)"
    data = dict(name="Rod", dept="Sales", location="Germany")
    cursor.setinputsizes(cx_Oracle.DB_TYPE_JSON)
    cursor.execute(sql, [data])
    

    To try the advantages of the new storage type, you can use Oracle Database 21c in Oracle Cloud. See my earlier blog post How to connect to Oracle Autonomous Cloud Databases. Oracle Instant Client 21 is currently available only for Linux.

    Existing cx_Oracle JSON features - which also support the BLOB, CLOB and VARCHAR storage for JSON available since Oracle Database 12c - remain unchanged.

    See the cx_Oracle Working with the JSON Data Type documentation and the Database JSON Developer's Guide for more goodness about working with JSON.

  • SODA (the NoSQL-style API) in Oracle Database 21c now takes advantage of the new JSON storage format by default. If you're using SODA with different versions of Oracle Client library connected to Oracle Database 21, review the cx_Oracle SODA Requirements.

    Now that Oracle Instant Client 21 is available, don't forget that some existing cx_Oracle 8.0 SODA features such as SodaCollection.save(), SodaCollection.saveAndGet(), and SodaCollection.truncate() that require recent client libraries are easier for you to take advantage of. These also work when connected to older Oracle database versions once cx_Oracle is using the new client libraries.

See the release notes for all changes.

Installing or Upgrading cx_Oracle

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. See cx_Oracle Installation for details.

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.