manojjahgirdar / db2-on-cpd-notebook

Home Page:https://manojjahgirdar.github.io/db2-on-cpd-notebook/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to Fix: Insert Pandas DataFrame from Db2 issue on Cloud Pak for Data Notebook

Issue

There is a recent issue with Cloud Pak for Data's Jupyter Notebook. When you try to insert Pandas DataFrame from a DB2 connection, it adds the code snippet however, running the code snippet will give an error.

error

ProgrammingError: ibm_db_dbi::ProgrammingError: [IBM][CLI Driver] SQL10013N  The specified library "GSKit Error: 2" could not be loaded.  SQLSTATE=42724 SQLCODE=-10013

Solution/Workaround

This issue is caused because the SSL Certificate is base 64 encoded.

before

You will have to decode the SSL Certificate in order to authenticate with Db2.

  • You can decode the base64 encoded string in just 2 steps:
    • Import base64 and copy the base64 encoded ssl certificate into a variable

      import base64
      certificate = <Your ssl certificate>

      copycertificate

    • Decode base64 string into bytes and decode the bytes into ascii. Write the decoded ssl certificate to the file.

      ssl_certificate_bytes = base64.b64decode(certificate)
      ssl_certificate = ssl_certificate_bytes.decode('ascii')
      
      ...
      
      f.write(ssl_certificate)

      sslcert

Once you have incorporated these changes you can run the code block and the Pandas DataFrame will be loaded with the Db2 table.

errorsolved