Skip to content

[BUG]: Test failure if system ODBC libraries are not installed: test_execute_query_without_connection #1549

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
1 task done
asnare opened this issue May 1, 2025 · 0 comments · May be fixed by #1550
Open
1 task done
Assignees
Labels
bug Something isn't working internal technical pr's not end user facing

Comments

@asnare
Copy link
Contributor

asnare commented May 1, 2025

Is there an existing issue for this?

  • I have searched the existing issues

Category of Bug / Issue

Other

Current Behavior

The test_execute_query_without_connection unit test fails if the system libraries for ODBC are not unavailable. This is an undocumented project requirement, with an ImportError being triggered if the native libraries cannot be found.

Expected Behavior

This test should be skipped if:

  1. Not running under the CI environment;
  2. The ODBC libraries are unavailable.

Alternatively, the project setup/requirements for local development should be updated. (Installing the ODBC libraries is not within the scope of hatch/pip: they are limited to installing Python libraries in the local virtual environment.)

Steps To Reproduce

  1. On a macOS, verify that unixodbc is not installed.
  2. Run the project tests:
    HATCH_PYTHON=$(which python3.10) make clean dev test
  3. The test_execute_query_without_connection test will fail with an ImportError because pyodbc cannot load the native library.

Relevant log output or Exception details

FAILED
tests/unit/connections/test_database_manager.py:47 (test_execute_query_without_connection)
def test_execute_query_without_connection():
>       db_manager = DatabaseManager("mssql", sample_config)

tests/unit/connections/test_database_manager.py:49: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
src/databricks/labs/remorph/connections/database_manager.py:83: in __init__
    self.connector = _create_connector(db_type, config)
src/databricks/labs/remorph/connections/database_manager.py:54: in _create_connector
    return connector_class(config)
src/databricks/labs/remorph/connections/database_manager.py:28: in __init__
    self.engine: Engine = self._connect()
src/databricks/labs/remorph/connections/database_manager.py:78: in _connect
    return create_engine(connection_string)
<string>:2: in create_engine
    ???
.venv/lib/python3.10/site-packages/sqlalchemy/util/deprecations.py:281: in warned
    return fn(*args, **kwargs)  # type: ignore[no-any-return]
.venv/lib/python3.10/site-packages/sqlalchemy/engine/create.py:602: in create_engine
    dbapi = dbapi_meth(**dbapi_args)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

cls = <class 'sqlalchemy.dialects.mssql.pyodbc.MSDialect_pyodbc'>

    @classmethod
    def import_dbapi(cls) -> ModuleType:
>       return __import__("pyodbc")
E       ImportError: dlopen(/Users/**REDACTED**/dev/remorph-2/.venv/lib/python3.10/site-packages/pyodbc.cpython-310-darwin.so, 0x0002): Library not loaded: /usr/local/opt/unixodbc/lib/libodbc.2.dylib
E         Referenced from: <13D74168-289F-36F6-8E48-C5C94BC764C8> /Users/**REDACTED**/dev/remorph-2/.venv/lib/python3.10/site-packages/pyodbc.cpython-310-darwin.so
E         Reason: tried: '/usr/local/opt/unixodbc/lib/libodbc.2.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/usr/local/opt/unixodbc/lib/libodbc.2.dylib' (no such file), '/usr/local/opt/unixodbc/lib/libodbc.2.dylib' (no such file), '/usr/local/lib/libodbc.2.dylib' (no such file), '/usr/lib/libodbc.2.dylib' (no such file, not in dyld cache)

.venv/lib/python3.10/site-packages/sqlalchemy/connectors/pyodbc.py:60: ImportError

Operating System

macOS

Version

latest via Databricks CLI

@asnare asnare added bug Something isn't working internal technical pr's not end user facing labels May 1, 2025
@asnare asnare self-assigned this May 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working internal technical pr's not end user facing
Projects
None yet
1 participant