{"record":{"id":"c9793875434cde27","repo":"cocoindex-io/cocoindex","slug":"aiomysql-is-required-for-async-doris-connections","errorCode":null,"errorMessage":"aiomysql is required for async Doris connections. Install it with: pip install aiomysql","messagePattern":"aiomysql is required for async Doris connections\\. Install it with: pip install aiomysql","errorType":"exception","errorClass":"ImportError","httpStatus":null,"severity":"error","filePath":"python/cocoindex/connectors/doris/_target.py","lineNumber":1371,"sourceCode":"\n\n# ============================================================\n# Query helpers\n# ============================================================\n\n\nasync def connect_async(\n    fe_host: str,\n    query_port: int = 9030,\n    username: str = \"root\",\n    password: str = \"\",\n    database: str | None = None,\n) -> Any:\n    \"\"\"Connect to Doris via MySQL protocol (async, using aiomysql).\"\"\"\n    try:\n        import aiomysql  # type: ignore\n    except ImportError:\n        raise ImportError(\n            \"aiomysql is required for async Doris connections. \"\n            \"Install it with: pip install aiomysql\"\n        )\n    return await aiomysql.connect(\n        host=fe_host,\n        port=query_port,\n        user=username,\n        password=password,\n        db=database,\n        autocommit=True,\n    )\n\n\ndef build_vector_search_query(\n    table: str,\n    vector_field: str,\n    query_vector: list[float],\n    metric: str = \"l2_distance\",","sourceCodeStart":1353,"sourceCodeEnd":1389,"githubUrl":"https://github.com/cocoindex-io/cocoindex/blob/e84aa99b3292c5270a4b313b2a7137ad9ce8ab3b/python/cocoindex/connectors/doris/_target.py#L1353-L1389","documentation":"The async MySQL-protocol connection helper for Doris depends on the optional third-party package aiomysql. It is not a hard dependency of cocoindex, so connect_async imports it lazily and raises ImportError with install instructions when missing.","triggerScenarios":"Calling connect_async (or any query path that uses it, e.g. vector search execution) in an environment where aiomysql was never installed.","commonSituations":"Fresh deployment/CI environment where the extras group wasn't installed; switching from sync (pymysql installed) to async usage; slim Docker images without optional deps.","solutions":["Install the dependency: pip install aiomysql","Or install the doris extra if provided: pip install 'cocoindex[doris]'","Alternatively use the sync connection helper if async is not required"],"exampleFix":"// before\npip install cocoindex\n// after\npip install cocoindex aiomysql","handlingStrategy":"fallback","validationCode":"import importlib.util\nassert importlib.util.find_spec(\"aiomysql\"), \"pip install aiomysql\"","typeGuard":null,"tryCatchPattern":"try:\n    conn = await connect_async(host, port, user, password, db)\nexcept ImportError:\n    conn = connect_sync(host, port, user, password, db)  # pymysql fallback","preventionTips":["Add aiomysql to your project requirements/extras when using the Doris connector","Verify imports in CI with a smoke test","Document the optional dependency for your deployment images"],"tags":["doris","dependency","import","async"],"backgroundTag":"missing-optional-dependency","analyzedSha":"e84aa99b3292c5270a4b313b2a7137ad9ce8ab3b","analyzedAt":"2026-09-08T15:59:19.997Z","contentChangedAt":"2026-09-08T15:59:19.997Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}