Skip to main content
New Participant
Nov 20, 2024 5:46 PM UTC
Question

connection to Oracle 19C from Python running on zOS USS

Anybody have tried to connect Python on z/OS to Oracle database. I'd appreciate any tips and clues.

    3 replies

    Ronald Funk
    New Participant
    Nov 21, 2024 11:17 PM UTC

    Anybody have tried to connect Python on z/OS to Oracle database. I'd appreciate any tips and clues.

    Hi Valentin,

    we do not have Oracle Databases here and I do not have any experience with Oracle Databases, but here are two suggestions you can try: 

    1. Did you try to install the oracle client cx_oracle in z/OS? 
    •  You need to have access from inside z/OS to pypi.org
    • It looks like the client uses a C library. The library needs to be compiled and linked in z/OS. You need to have the new LLVM based Open XLC/C++ Compiler installed and configured in z/OS. Open XL C/C++ is fully based on the LLVM open source Clang infrastructure and supports current C/C++ language standards and the latest IBM z16™ servers. In order to install and use the new compiler you need to have a license for  z/OS XL C/C++  though. 
    • I gave the installation a quick try inside the z/Unix shell:              

                  ##
                  # Exports requirec for IBM C/C++ For Open Enterprise Languages on z/OS 2.0
                  #
                 # Usage: source oelcv2.sh
                 #
                 export CC=/usr/lpp/IBM/oelcpp/v2r0/bin/clang
                 export CXX=/usr/lpp/IBM/oelcpp/v2r0/bin/clang
                 export LDSHARED=/usr/lpp/IBM/oelcpp/v2r0/bin/clang
                 export PATH=/usr/lpp/IBM/oelcpp/v2r0/bin/:$PATH
                #
                # Exports for ASCII applications
                #
                export _BPXK_AUTOCVT='ON'
                export _CEE_RUNOPTS='FILETAG(AUTOCVT,AUTOTAG) POSIX(ON)'
                export _TAG_REDIR_ERR="txt"
                export _TAG_REDIR_IN="txt"
                export _TAG_REDIR_OUT="txt"

                . .venv/bin/activate

                  python -m pip install cx_Oracle --upgrade

                  /usr/lpp/IBM/oelcpp/v2r0/bin/clang -DNDEBUG -O3 -D_XOPEN_SOURCE_EXTENDED -D_UNIX03_THREADS -D_POSIX_THREADS -D_OPEN_SYS_FILE_EXT -m64 -       fvisibility=default -fzos-le-char-mode=ascii -fno-short-enums -DCXO_BUILD_VERSION=8.3.0 -Iodpi/include -Iodpi/src -I/u/xv880aj/Documents/source/git/jiraissue/venv/include -I/RS0BA1/usr/lpp/road4z/include/python3.12 -c odpi/src/dpiConn.c -o build/temp.os390-29.00-8561-cpython-312/odpi/src/dpiConn.o

    as you can see, the package installation calls the Open XLC compiler. From here on you are on your own with this one ;-) good luck.

    2. Did you try the Oracle Database REST API? From my point of view the way to go :-) Just use the Python requests package and it should be no problem to access the database. I used the package a lot inside z/OS z/Unix and know it does install and work very well.

    regards

    Ronny

    New Participant
    Nov 22, 2024 7:34 AM UTC

    Anybody have tried to connect Python on z/OS to Oracle database. I'd appreciate any tips and clues.

    Hi Rony,

    I Appreciate your timely advice. I'll follow through on it with my zOS software team. I'll post any progress here.

    Thank you!

    Val.

    Jorn Thyssen
    Rocketeer
    Nov 25, 2024 10:05 AM UTC

    Anybody have tried to connect Python on z/OS to Oracle database. I'd appreciate any tips and clues.

    Hi Valentin,

    Connecting directly as suggested above is the best option, but there might be a different option if you already have a DRDA connection from a local Db2 for z/OS subsystem to Oracle (this requires some middleware from IBM or Oracle like Oracle DRDA Gateway). 

    In that case you can use ibm_db to connect to the local Db2 for z/OS, and then use the remote connection to get to Oracle.