Skip to content

Commit

Permalink
Connect to "ibm_db" - fix "user" and "password" params, which must be…
Browse files Browse the repository at this point in the history
… set empty, allow custom params in connection string (similar to pyodbc), "TCPIP" is no default protocol value anymore
  • Loading branch information
amochin committed Sep 30, 2024
1 parent 611b1d0 commit 82da587
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions src/DatabaseLibrary/connection_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -389,10 +389,25 @@ def _arg_or_config(arg_value, param_name, *, old_param_name=None, mandatory=Fals

elif db_module in ["ibm_db", "ibm_db_dbi"]:
db_port = db_port or 50000
con_str = (
f"DATABASE={db_name};HOSTNAME={db_host};PORT={db_port};PROTOCOL=TCPIP;UID={db_user};PWD={db_password};"
)
con_params = _build_connection_params(userID="", userPassword="")
con_str = ""
if db_name:
con_str += f"DATABASE={db_name};"
if db_user:
con_str += f"UID={db_user};"
if db_password:
con_str += f"PWD={db_password};"
if db_host:
con_str += f"HOSTNAME={db_host};"
if db_port:
con_str += f"PORT={db_port};"

for param_name, param_value in custom_connection_params.items():
con_str += f"{param_name}={param_value};"

for param_name, param_value in other_config_file_params.items():
con_str += f"{param_name}={param_value};"

con_params = _build_connection_params(custom_params=False, user="", password="")
_log_all_connection_params(connection_string=con_str, **con_params)
db_connection = db_api_2.connect(con_str, **con_params)

Expand Down

0 comments on commit 82da587

Please sign in to comment.