Skip to content

Latest commit

 

History

History
96 lines (76 loc) · 3.55 KB

install.md

File metadata and controls

96 lines (76 loc) · 3.55 KB

Installing IBM Python & ODBC on z/OS

Below steps were to be followed for the same:

  1. Tested under below versions:
-- zODBC(64 bit) installed with z/OS 2.3
-- IBM Python 3.8.3 64 bit_

Installing IBM Python & ODBC on z/OS

Below steps were followed for the same:

  1. Tested under below:
-- zODBC(64 bit) installed with z/OS 2.3
-- IBM Python 3.8.3 64 bit
-- Install the below PTFs(If not installed):
    -- UI72588 (v11)
    -- UI72589 (v12)
  1. Configure below environment variables for install/compilation or create a shell profile (i.e. ". profile" file in your home environment) which includes environment variables, needed for Python and DB2 for z/OS ODBC(make sure all the below paths are changed based on your system and DB setting and all the variables are configured with none missed).
  • NOTE(Default behaviour):
    • IBM_DB_HOME is the HLQ for your DB2 libraries(SDSNMACS, SDSNC.H)

e.g.

#Code page autoconversion i.e. USS will automatically convert between ASCII and EBCDIC where needed.
export _BPXK_AUTOCVT='ON'
export _CEE_RUNOPTS='FILETAG(AUTOCVT,AUTOTAG) POSIX(ON) XPLINK(ON)'
export PATH=$HOME/bin:/user/python_install/bin:$PATH
export LIBPATH=$HOME/lib:/user/python_install/lib:$PATH
export STEPLIB=XXXX.DSN.VC10.SDSNLOAD
export STEPLIB=XXXX.DSN.VC10.SDSNLOD2:$STEPLIB
export STEPLIB=XXXX.SDSNEXIT:$STEPLIB
export IBM_DB_HOME=XXXX.DSN.VC10
export DSNAOINI=$HOME/odbc_XXXX.ini

In case you have data Set named anything other than SDSNC.H i.e. non default behaviour, you need to configure following variable. IGNORE OTHERWISE.

export DB2_INC=$IBM_DB_HOME.XXXX.H

In case you have SDSNMACS data Set named anything other than SDSNMACS i.e. non default behaviour, you need to configure following variable. IGNORE OTHERWISE.

export DB2_MACS=$IBM_DB_HOME.XXXX
  1. Make sure when python is installed, you validate the same by typing "python3 -V" and it should return 3.8.3 or greater.
  • Unless you are a sysprog you'll likely not have authority to create the site-package so consider using a python virtual environment as following:
python3 -m venv $HOME/ibm_python_venv
source $HOME/ibm_python_venv/bin/activate
  1. Make sure "pip3" is installed and enabled as part of Python installation and is working.

  2. ODBC installed connects and works with the DB2 for z/OS on the same subsytem or Sysplex with details configured in ".ini" file. No additional setting has to be done or credentials needs to be given during connection creation in python program. e.g.

import ibm_db
conn = ibm_db.connect('','','')

Installing Python driver for DB2 i.e. ibm_db & Running a validation Program

Now that the Python and ODBC is ready, for connecting to DB2 you need a DB2 Python driver which we are going to install.

Follow the standard steps for the same i.e. pip3 install ibm_db

Now assuming everything went fine. You can run a test program i.e. odbc_test.py with below content to validate if the setup has been done perfectly i.e. bash-4.3$ python3 odbc_test.py:

from __future__ import print_function
import sys
import ibm_db
print('ODBC Test start')
conn = ibm_db.connect('','','')
if conn:
    stmt = ibm_db.exec_immediate(conn,"SELECT CURRENT DATE FROM SYSIBM.SYSDUMMY1")
    if stmt:
        while (ibm_db.fetch_row(stmt)):
            date = ibm_db.result(stmt, 0)
            print("Current date is :",date)
    else:
        print(ibm_db.stmt_errormsg())
    ibm_db.close(conn)
else:
    print("No connection:", ibm_db.conn_errormsg())
print('ODBC Test end')