Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
languagepy
themeMidnight
linenumberstrue
import ibm_db
import pandas as pd

db = 'PR_SAIL'
hostname = 'db2.database.ukserp.ac.uk'
port = '60070'
protocol = 'TCPIP'
uid = 'YOUR USERNAME HERE'
pwd = 'YOUR PASSWORD HERE'
security = 'ssl'
ssl_client_keystoredb = '/db2conn/chi.kdb'
ssl_client_keystash = '/db2conn/chi.sth'

conn_str = ("DATABASE={0};"
			"HOSTNAME={1};"
			"PORT={2};"
			"PROTOCOL={3};"
			"Security={4};"
			"UID={5};"
			"PWD={6};"
			"SSLClientKeystoredb={7};"
			"SSLClientKeystash={8};").format(db, hostname, port, protocol, uid, pwd, ssl_client_keystoredb, ssl_client_keystash)

conn = ibm_db.connect(conn_str, '', '') 
stmtpd_conn = ibm_db_dbi.exec_immediateConnection(conn, ")

q = 'SELECT * FROM syscat.tables LIMIT 3")
print "Number of affected rows: ", ibm_db.num_rows(stmt5'
df = pd.read_sql(q, pd_conn)
print(df)

Alternative Python option:

...