skip to Main Content

I have tried multiple docker images including centos7, centos8, debian, python, ubuntu.
But every where its a dead end.
I am able to connect from node js from same docker build.
Even using python it is successfully connecting to db2 from windows but when I use python in docker it fails with License error

File "/usr/local/lib/python3.8/site-packages/sqlalchemy/pool/base.py", line 656, in __connect
    connection = pool._invoke_creator(self)
  File "/usr/local/lib/python3.8/site-packages/sqlalchemy/engine/strategies.py", line 114, in connect
    return dialect.connect(*cargs, **cparams)
  File "/usr/local/lib/python3.8/site-packages/sqlalchemy/engine/default.py", line 493, in connect
    return self.dbapi.connect(*cargs, **cparams)
  File "/home/service/ibm_db_dbi.py", line 1188, in connect
    raise _get_exception(inst)
sqlalchemy.exc.ProgrammingError: (ibm_db_dbi.ProgrammingError) ibm_db_dbi::ProgrammingError: Exception('[IBM][CLI Driver] SQL1598N  An attempt to connect to the database server failed because of a licensing problem.  SQLSTATE=42968 SQLCODE=-1598')

DockerFile

FROM python

USER root
WORKDIR /home/service
ADD ./ /home/service

RUN python --version
RUN pip install -r requirements.txt
RUN cp db2consv_ee.lic /usr/local/lib/python3.8/site-packages/clidriver/license/

requirements.txt

ibm_db==3.0.2
ibm-db-sa==0.3.5
SQLAlchemy==1.3.18

Python script

from sqlalchemy import Column, Integer, String, MetaData
from sqlalchemy import create_engine
engine = create_engine("db2+ibm_db://userId:password@host:port/db") #create a database engine
from sqlalchemy.ext.declarative import declarative_base
metadata = MetaData(schema='schemaName')
Base = declarative_base(bind=engine, metadata=metadata)

class Customers(Base):
   __tablename__ = 'tableName'
   CLIENT_ID = Column(Integer, primary_key=True)
   CLIENT_NAME = Column(Integer)
   CREATED_BY = Column(String)

from sqlalchemy.orm import sessionmaker
Session = sessionmaker(bind = engine)
session = Session()
result = session.query(Customers).limit(2)

for row in result:
   print (row.CLIENT_NAME )

2

Answers


  1. Chosen as BEST ANSWER

    All the packages like npm or pip fetches the driver from https://public.dhe.ibm.com/ibmdl/export/pub/software/data/db2/drivers/odbc_cli/ . And they randomly update the file without maintaining the versions. All the versions are maintained in https://www.ibm.com/support/pages/node/323035 Their is some issue with latest version of clidriver(11.5) which is mapped to the link https://public.dhe.ibm.com/ibmdl/export/pub/software/data/db2/drivers/odbc_cli/

    Instead, I am able to resolve it by downloading 11.1 version from https://www.ibm.com/support/docview.wss?uid=ibm11116777

    For linux downloaded as there are no 64bit driver for odbc-cli so downloaded IBM Data Server Runtime Client Linux x86 and extracted the v11.1.4fp5_linuxx64_dsdriver.tar.gz and replaced node_modules/ibm_db/installer/ and /usr/local/lib/python3.7/site-packages/ with v11.1.4fp5_linuxx64_dsdriver.tar.gzv11.1.4fp5_linuxx64_dsdriver.tardsdriverodbc_cli_driverlinuxamd64

    For windows : IBM Data Server Driver for ODBC and CLI (64-bit) and replaced node_modules/ibm_db/installer/ and /usr/local/lib/python3.7/site-packages/ with Windows 64bit


  2. SQL1598N is due to use of db2 v11.1 license file that you are using to connect to Db2 for z/OS or Db2 for iSeries. The new ibm_db driver requires db2 v11.5 db2connect license to connect to z/OS and iSeries servers.
    So, simple way to solve SQL1598N error is to upgrade the license file. If you open the db2consv_*.lic file in an editor, you can see the version is mentioned in it.
    If you want to continue with existing v11.1 license, need to follow below steps:

    1. Download https://public.dhe.ibm.com/ibmdl/export/pub/software/data/db2/drivers/odbc_cli/linuxx64/linuxx64_odbc_cli.tar.gz
    2. untar it, you’ll get clidriver directory.
    3. export IBM_DB_HOME=<full_path_of_clidriver>
    4. copy v11.1 db2consv_*.lic file under clidriver/license directory
    5. pip install ibm_db

    It should work fine now. Thanks.

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