skip to Main Content

I am trying to execute ETL pipeline through Azure function that fetches data from an Oracle DB and puts into a MySQL db.

I put cx_oracle in requirements.txt but got below error:

cx_Oracle.DatabaseError: DPI-1047: Cannot locate a 64-bit Oracle Client library: "libclntsh.so: cannot open shared object file: No such file or directory".

For python oracle library cx_oracle, it requires installation of oracle clients. How do i install those dependencies, put their path on environment variable and then start execute my code on every function trigger? Is it even possible?

2

Answers


  1. By default, Functions are running in a sandbox and you can’t install 3rd party tools like the Oracle client. One solution is to package your app + dependencies in a Docker container and configure your Function to run the container.

    Documentation

    Login or Signup to reply.
  2. The best solution is to use the latest version of cx_Oracle which doesn’t always need Oracle Client libraries – these are optional if you want extended functionality.

    Python-oracledb 1.0 is the upgrade from cx_Oracle 8.3, under a new name. See
    the release
    announcement
    .

    Installing and using python-oracledb is like:

    python -m pip install oracledb
    

    And then you can run scripts like:

    import oracledb
    
    connection = oracledb.connect(user='scott', password=mypw, dsn='myhost/oraclepdb1')
    with connection.cursor() as cursor:
      for row in cursor.execute('select city from locations'):
          print(row)
    

    Note that oracledb.connect() calls now require named "keyword" parameters,
    conforming to the Python DB API specification.

    If you already have some scripts and don’t want to change the namespace on every call try changing the
    import like:

    import oracledb as cx_Oracle
    

    Home page: oracle.github.io/python-oracledb/

    Quick start: Quick Start python-oracledb Installation

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

    PyPI: pypi.org/project/oracledb/

    Source: github.com/oracle/python-oracledb

    Upgrading: Upgrading from cx_Oracle 8.3 to python-oracledb

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search