{"record":{"id":"9554fe7aeefa33c0","repo":"zylon-ai/private-gpt","slug":"db2-database-query-dependencies-are-not-installed-9554fe","errorCode":null,"errorMessage":"DB2 database query dependencies are not installed. Install with one of: `uv sync --inexact --extra database-db2` or `uv sync --inexact --extra database`.","messagePattern":"DB2 database query dependencies are not installed\\. Install with one of: `uv sync --inexact --extra database-db2` or `uv sync --inexact --extra database`\\.","errorType":"exception","errorClass":"ImportError","httpStatus":null,"severity":"error","filePath":"private_gpt/components/tabular/database_query_generator.py","lineNumber":87,"sourceCode":"        format_missing_dependency_message(\n            \"Database query\",\n            extras=(\n                \"database-postgres\",\n                \"database-mysql\",\n                \"database-mssql\",\n                \"database-db2\",\n                \"database\",\n            ),\n        )\n    ) from e\n\n\n@functools.cache\ndef _load_ibm_db() -> Any:\n    try:\n        import ibm_db  # type: ignore[import-not-found]  # ty:ignore[unresolved-import]\n    except ImportError as e:\n        raise ImportError(\n            format_missing_dependency_message(\n                \"DB2 database query\",\n                extras=(\"database-db2\", \"database\"),\n            )\n        ) from e\n\n    return ibm_db\n\n\nclass ErrorType(enum.StrEnum):\n    UNKNOWN = \"UNKNOWN\"\n    NOT_SUPPORTED_TYPE_MSSQL = \"HY106\"  # Error code for MSSQL unsupported type\n    RETURNED_SQL_CURSOR = (\n        \"RETURNED_SQL_CURSOR\"  # Postgres procedure returned a SQL cursor\n    )\n    INVALID_PARAM_MODE_DB2 = (\n        \"42886\"  # DB2 procedure invalid parameter mode (e.g., OUT param used as IN)\n    )","sourceCodeStart":69,"sourceCodeEnd":105,"githubUrl":"https://github.com/zylon-ai/private-gpt/blob/4a030776a31a901ad80b1bf4d7faa2c1a367efbb/private_gpt/components/tabular/database_query_generator.py#L69-L105","documentation":"Raised by the cached helper _load_ibm_db() when the ibm_db driver cannot be imported. Only the DB2 code path needs it, so the top-level sqlglot extra is not enough — the DB2-specific extra (database-db2 or database) must be installed. The helper is functools.cache'd, so after a failed attempt in the same process the ImportError is re-raised from cache; after installing the package you must restart the process.","triggerScenarios":"Configuring a DB2 connection (TSQL-adjacent DB2 dialect path) and executing a query, which triggers _load_ibm_db() without the ibm_db package installed.","commonSituations":"Installing --extra database-postgres for sqlglot but then pointing the connector at a DB2 URL; ibm_db installed in a different venv than the running app; platform wheels for ibm_db missing on the host.","solutions":["Run: uv sync --inexact --extra database-db2 (or --extra database)","Confirm the active interpreter matches the venv where ibm_db is installed: python -c \"import ibm_db\"","Restart the application after installing (module-level and cached imports do not pick up new packages mid-process)"],"exampleFix":"# terminal — before: ValueError/ImportError on DB2 query\nuv sync --inexact --extra database-db2\n# after: restart app, DB2 queries proceed past driver load","handlingStrategy":"validation","validationCode":"import importlib.util\n\nif importlib.util.find_spec(\"ibm_db\") is None:\n    raise SystemExit(\n        \"DB2 support requires ibm_db: uv sync --inexact --extra database-db2\"\n    )","typeGuard":"def db2_driver_available() -> bool:\n    import importlib.util\n    return importlib.util.find_spec(\"ibm_db\") is not None","tryCatchPattern":"try:\n    sql = generator.generate(...)\nexcept ImportError as e:\n    if \"database-db2\" not in str(e):\n        raise\n    raise SystemExit(\"install extra: uv sync --inexact --extra database-db2\") from e","preventionTips":["Check for the ibm_db driver before configuring a DB2 connection","Restart the process after installing — _load_ibm_db caches failures"],"tags":["database","db2","dependencies","import","installation"],"backgroundTag":null,"analyzedSha":"4a030776a31a901ad80b1bf4d7faa2c1a367efbb","analyzedAt":"2026-08-15T03:51:26.951Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}