Connecting to DB2 with SSL using Python's SQL Alchemy

3,538 views
Skip to first unread message

Benjamin Singleton

unread,
Jul 24, 2017, 11:35:02 PM7/24/17
to ibm_db

Hi,

I was hoping that somewhere here could walk me through connecting to a DB2 database with SSL enabled using Python's SQL Alchemy. In the past (prior to SSL), I had successfully connected as follows:

** Note: I first used easy_install to install ibm_db and ibm_db_sa.

from sqlalchemy import create_engine

engine = create_engine(r"db2+ibm_db://username:pass...@host.com:port/schema")

 

How do I amend this code to connect using SSL?

Thanks for your assistance,
Ben

Cam

unread,
Oct 29, 2017, 11:50:10 PM10/29/17
to ibm_db
I'm having the same issue

Saba Kauser

unread,
Oct 30, 2017, 12:07:04 AM10/30/17
to ibm_db
Can you try the following:

import sqlalchemy

from sqlalchemy import *

import ibm_db_sa

db2 =sqlalchemy.create_engine('ibm_db_sa://username:password@host:port/databser;SECURITY=SSL;SSLCLIENTKEYSTOREDB=path to *.kdb;SSLCLIENTKEYSTASH=path to *.sth;')

conn = db2.connect()


or


import sqlalchemy

from sqlalchemy import *

import ibm_db_sa

db2 =sqlalchemy.create_engine('ibm_db_sa://username:password@host:port/databse;SECURITY=SSL;SSLServerCertificate=server.arm;')

conn = db2.connect()

 

You can find more information on setting up SSL connection here:

https://www.ibm.com/support/knowledgecenter/SSEPGG_11.1.0/com.ibm.db2.luw.admin.sec.doc/doc/t0053518.html

Reply all
Reply to author
Forward
0 new messages