Start of change

Troubleshooting IBM_DB Python driver support through Db2 for z/OS ODBC

If you encounter problems when the IBM_DB Python driver accesses data through Db2 for z/OS ODBC, you can enable the application trace to collect diagnostics data for the problem.

Before you begin

  • If the application fails with SQLCODE -805, the likely reason is that the Db2 for z/OS ODBC packages are not correctly bound. You can find a customizable sample JCL job in member DSNTIJCL of the SDSNSAMP data set. For more information, see Db2 ODBC run time environment setup.
  • If the application packages are already bound, ensure that the correct bind options and DBRM library are used. Then, check the settings in the ODBC initialization file.
  • If you are unsure whether the problem is related to the IBM_DB Python driver or Db2 for z/OS ODBC, open a case with IBM® Support for Db2 for z/OS.
  • If you are certain that the problem is related to Python or the IBM_DB Python driver, open a case with IBM Support for IBM Open Enterprise Python for z/OS.

Procedure

If you suspect the problem is related to ODBC CLI driver support of the IBM_DB Python driver, collect the following diagnostics items before you open a support case with IBM Support for Db2 for z/OS ODBC.

  1. Enable the following traces in the ODBC initialization file:
    1. Enable the application trace with the following keywords:
      APPLTRACE=1
      APPLTRACEFILENAME=appltrace-filename 
      appltrace-filename must be a z/OS UNIX System Services HFS file name.
    2. Enable the diagnostics trace with the following keywords:
      DIAGTRACE=1
      DIAGTRACE_BUFFER_SIZE = buffer-size
      
    For more information about setting these trace options, see Db2 ODBC initialization keywords.
  2. Check the format and settings in the ODBC initialization file:
    Start of changeIf an error occurs for ibm_db.connect() and no application trace file is generated:End of change
    Start of changeThe problem might be an incorrect text flag setting for the initialization file.
    1. To check the format, issue the following command :
      $  chtag -p $DSNAOINI

      You might see the following output:

      t IBM-1047    T=on  file1
    2. Issue one of the following commands:
      Data format Command to issue
      Binary data
      chtag -b $DSNAOINI
      Mixed data
      chtag -m -c IBM-1047 $DSNAOINI
    3. Issue the following command again to verify the update:
      $  chtag -p $DSNAOINI

      The expected output, which depends on the data format of the initialization file, is similar to the following examples:

      Data format Expected output
      Binary
      b binary      T=off file1
      Mixed
      m IBM-1047    T=off file2
    End of change
    If a configuration keyword is unrecognized:
    • The encoding scheme of the ODBC initialization file must be EBCDIC.
    • The keywords must be defined in the correct sections (common, subsystem, or data source) of the ODBC initialization file.
  3. If the application trace is not readable by using the cat trace file name, complete the following steps:
    1. Issue the following command to check the trace format:
      ls -lT appltrace-filename

      If the application trace file is not in EBCDIC format, something like the following output might be returned:

      t ISO8859-1 T=on
    2. Issue the following command to make the application trace file readable:
      chgtag -tc IBM-1047 appltrace-filename
End of change