Skip to content

Commit fb7450d

Browse files
authored
Fixes 'unable to import module' on Windows (#18908)
* Update ibm_db2.py fix unable to import module on Windows * Update README.md * reverse
1 parent f3dbc6b commit fb7450d

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

ibm_db2/changelog.d/18908.fixed

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fixes 'unable to import module' on Windows

ibm_db2/datadog_checks/ibm_db2/ibm_db2.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,21 @@
66
from itertools import chain
77
from time import time as timestamp
88

9-
import ibm_db
109
from requests import ConnectionError
1110

1211
from datadog_checks.base import AgentCheck, is_affirmative
1312
from datadog_checks.base.utils.containers import iter_unique
13+
from datadog_checks.base.utils.platform import Platform
14+
15+
if Platform.is_windows():
16+
# After installing ibm_db, dll path of dependent library of clidriver must be set before importing the module
17+
# Ref: https://github.com/ibmdb/python-ibmdb/#installation
18+
import os
19+
20+
embedded_lib = os.path.dirname(os.path.abspath(os.__file__))
21+
os.add_dll_directory(os.path.join(embedded_lib, 'site-packages', 'clidriver', 'bin'))
22+
23+
import ibm_db
1424

1525
from . import queries
1626
from .utils import get_version, scrub_connection_string, status_to_service_check

0 commit comments

Comments
 (0)