Skip to content

Commit

Permalink
Fixes 'unable to import module' on Windows (#18908)
Browse files Browse the repository at this point in the history
* Update ibm_db2.py

fix unable to import module on Windows

* Update README.md

* reverse
  • Loading branch information
ian28223 authored Nov 19, 2024
1 parent f3dbc6b commit fb7450d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
1 change: 1 addition & 0 deletions ibm_db2/changelog.d/18908.fixed
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fixes 'unable to import module' on Windows
12 changes: 11 additions & 1 deletion ibm_db2/datadog_checks/ibm_db2/ibm_db2.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit fb7450d

Please sign in to comment.