...
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
import ibm_db import ibm_db_dbi 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 = '/db2conndb2-connection/chi.kdb' ssl_client_keystash = '/db2conndb2-connection/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, security, uid, pwd, ssl_client_keystoredb, ssl_client_keystash) conn = ibm_db.connect(conn_str, '', '') pd_conn = ibm_db_dbi.Connection(conn) q = 'SELECT * FROM syscat.tables LIMIT 5' df = pd.read_sql(q, pd_conn) print(df) |
...