<jupyter_start><jupyter_text>Purpose: To test connecting to mainframe z/OS with `ibm_db` library<jupyter_code>from getpass import getpass
db = input("Enter database: ")
db_host = input("Enter Database Server Host Name: ")
db_port = input("Enter Database Port: ")
db_user = input("Enter db user id: ")
db_pw   = getpass("Enter db password: ")
db_table = input("Enter table: ")
import ibm_db
import ibm_db_dbi
import pandas as pd
conn_str=f"database={db};hostname={db_host};port={db_port};protocol=tcpip;uid={db_user};pwd={<PASSWORD>}"
ibm_db_conn = ibm_db.connect(conn_str,'','')<jupyter_output><empty_output><jupyter_text>Use `with` context manager to ensure connection will be closed<jupyter_code>with ibm_db_dbi.Connection(ibm_db_conn) as conn:
    sql = f"SELECT * FROM {db_table} fetch first 10 rows only"
    df = pd.read_sql(sql, conn)
df<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.12700228832951946, 'fraction_numerical': 0.002288329519450801, 'mean_word_length': 7.413461538461538, 'pattern_counts': {'":': 0, '<': 10, '<?xml version=': 0, '>': 10, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '238008', 'license': 'MIT', 'n_tokens_mistral': 318, 'n_tokens_neox': 314, 'n_words': 74, 'path': 'DB2/Connecting_To_zOS_ibm_db.ipynb', 'repo_name': 'pybokeh/jupyter-sql', 'size': '869'}