diff --git a/ibm_db2/changelog.d/18908.fixed b/ibm_db2/changelog.d/18908.fixed new file mode 100644 index 0000000000000..3dadc489fa0d5 --- /dev/null +++ b/ibm_db2/changelog.d/18908.fixed @@ -0,0 +1 @@ +Fixes 'unable to import module' on Windows diff --git a/ibm_db2/datadog_checks/ibm_db2/ibm_db2.py b/ibm_db2/datadog_checks/ibm_db2/ibm_db2.py index 455c020153df2..c46f65aeef75a 100644 --- a/ibm_db2/datadog_checks/ibm_db2/ibm_db2.py +++ b/ibm_db2/datadog_checks/ibm_db2/ibm_db2.py @@ -6,11 +6,21 @@ from itertools import chain from time import time as timestamp -import ibm_db from requests import ConnectionError from datadog_checks.base import AgentCheck, is_affirmative from datadog_checks.base.utils.containers import iter_unique +from datadog_checks.base.utils.platform import Platform + +if Platform.is_windows(): + # After installing ibm_db, dll path of dependent library of clidriver must be set before importing the module + # Ref: https://github.com/ibmdb/python-ibmdb/#installation + import os + + embedded_lib = os.path.dirname(os.path.abspath(os.__file__)) + os.add_dll_directory(os.path.join(embedded_lib, 'site-packages', 'clidriver', 'bin')) + +import ibm_db from . import queries from .utils import get_version, scrub_connection_string, status_to_service_check