{"record":{"id":"d97176f49e15dbaa","repo":"crewAIInc/crewAI","slug":"failed-to-load-data-from-mysql-e","errorCode":null,"errorMessage":"Failed to load data from MySQL: {e}","messagePattern":"Failed to load data from MySQL: (.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"lib/crewai-tools/src/crewai_tools/rag/loaders/mysql_loader.py","lineNumber":102,"sourceCode":"                    if len(content) > 100000:\n                        content = content[:100000] + \"\\n\\n[Content truncated...]\"\n\n                    return LoaderResult(\n                        content=content,\n                        metadata={\n                            \"source\": query,\n                            \"database\": connection_params[\"database\"],\n                            \"row_count\": len(rows),\n                            \"columns\": columns,\n                        },\n                        doc_id=self.generate_doc_id(source_ref=query, content=content),\n                    )\n            finally:\n                connection.close()\n        except Error as e:\n            raise ValueError(f\"MySQL database error: {e}\") from e\n        except Exception as e:\n            raise ValueError(f\"Failed to load data from MySQL: {e}\") from e\n","sourceCodeStart":84,"sourceCodeEnd":103,"githubUrl":"https://github.com/crewAIInc/crewAI/blob/754d7323beb2fd042e33444a115ea2d5a47193f0/lib/crewai-tools/src/crewai_tools/rag/loaders/mysql_loader.py#L84-L103","documentation":"Raised by MySQLLoader.load() for any non-pymysql exception during loading — the catch-all `except Exception` after the `except Error` clause. It typically fires before the DB is even reached: most commonly ModuleNotFoundError/ImportError because the module imports `connect`/`DictCursor`/`Error` from pymysql at import time in environments where pymysql is not installed, plus errors like URL parsing edge cases or dict/key errors while building connection params.","triggerScenarios":"Importing/running MySQLLoader in an environment where pymysql is not installed (crewai-tools without the rag/DB extra); any unexpected exception while assembling parameters or formatting results that is not a pymysql.Error.","commonSituations":"Slim Docker/CI images without the optional database extras; assuming the loader uses SQLAlchemy (already installed) when it actually requires pymysql; environments where the dependency was pruned by a lockfile.","solutions":["Install the driver: pip install pymysql (or `pip install crewai-tools[rag]` / `uv add pymysql`).","Read the chained cause ({e}) — if it is ModuleNotFoundError the fix is the install above; otherwise address the specific underlying error.","Pin and sync the environment (uv sync / pip install -r) so pymysql survives rebuilds."],"exampleFix":"# before\nresult = MySQLLoader().load(SourceContent('SELECT 1'), metadata={'db_uri': uri})  # ModuleNotFoundError wrapped\n\n# after\n# terminal: pip install pymysql\nresult = MySQLLoader().load(SourceContent('SELECT 1'), metadata={'db_uri': uri})","handlingStrategy":"validation","validationCode":"import importlib.util\\n\\ndef pymysql_available() -> bool:\\n    return importlib.util.find_spec('pymysql') is not None","typeGuard":null,"tryCatchPattern":"try:\\n    result = MySQLLoader().load(src, metadata={'db_uri': uri})\\nexcept ValueError as e:\\n    if 'Failed to load data from MySQL' in str(e) and not pymysql_available():\\n        raise RuntimeError('install pymysql: pip install pymysql') from e\\n    raise","preventionTips":["Install pymysql wherever MySQLLoader may run.","Add a dependency capability check at service startup.","Read the chained cause message — this wrapper hides the real error class."],"tags":["mysql","database","dependencies","pymysql"],"backgroundTag":null,"analyzedSha":"754d7323beb2fd042e33444a115ea2d5a47193f0","analyzedAt":"2026-08-15T04:06:56.746Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}