{"record":{"id":"33a0a6cb15e01295","repo":"mem0ai/mem0","slug":"azure-mysql-vector-store-requires-pymysql-and-dbut","errorCode":null,"errorMessage":"Azure MySQL vector store requires PyMySQL and DBUtils. Please install them using 'pip install pymysql dbutils'","messagePattern":"Azure MySQL vector store requires PyMySQL and DBUtils\\. Please install them using 'pip install pymysql dbutils'","errorType":"exception","errorClass":"ImportError","httpStatus":null,"severity":"error","filePath":"mem0/vector_stores/azure_mysql.py","lineNumber":14,"sourceCode":"import json\nimport logging\nimport re\nfrom contextlib import contextmanager\nfrom typing import Any, Dict, List, Optional\n\nfrom pydantic import BaseModel\n\ntry:\n    import pymysql\n    from dbutils.pooled_db import PooledDB\n    from pymysql.cursors import DictCursor\nexcept ImportError:\n    raise ImportError(\n        \"Azure MySQL vector store requires PyMySQL and DBUtils. \"\n        \"Please install them using 'pip install pymysql dbutils'\"\n    )\n\ntry:\n    from azure.identity import DefaultAzureCredential\n    AZURE_IDENTITY_AVAILABLE = True\nexcept ImportError:\n    AZURE_IDENTITY_AVAILABLE = False\n\nfrom mem0.vector_stores.base import VectorStoreBase\n\nlogger = logging.getLogger(__name__)\n\n_SAFE_IDENTIFIER_RE = re.compile(r'^[a-zA-Z_][a-zA-Z0-9_]{0,127}$')\n\n\ndef _validate_identifier(name: str, label: str = \"identifier\") -> str:","sourceCodeStart":1,"sourceCodeEnd":32,"githubUrl":"https://github.com/mem0ai/mem0/blob/001c235229be8795e3834520467bd0d661ed8f34/mem0/vector_stores/azure_mysql.py#L1-L32","documentation":"Raised at module import of mem0.vector_stores.azure_mysql when pymysql or dbutils (DBUtils' PooledDB) cannot be imported. The Azure MySQL store needs PyMySQL for the wire protocol and DBUtils for connection pooling; both are optional dependencies. Note that azure.identity failing to import is tolerated separately — only the pymysql/dbutils pair is fatal.","triggerScenarios":"Configuring vector_store.provider='azure_mysql' in an environment missing pymysql or dbutils; having PyMySQL but not DBUtils (they are separate packages); a slim Docker image built from core mem0ai requirements only.","commonSituations":"pip install mem0ai then selecting Azure MySQL; DBUtils package name confusion (pip package is 'dbutils', import is 'dbutils.pooled_db'); venv mismatch between install and run.","solutions":["pip install pymysql dbutils","Add both to requirements.txt / rebuild the Docker image","Verify: python -c \"import pymysql; from dbutils.pooled_db import PooledDB\"","Ensure the install lands in the same interpreter/venv your app runs under"],"exampleFix":"# before: ImportError: Azure MySQL vector store requires PyMySQL and DBUtils ...\nfrom mem0 import Memory\nm = Memory.from_config(azure_mysql_cfg)\n\n# after\n# pip install pymysql dbutils\nfrom mem0 import Memory\nm = Memory.from_config(azure_mysql_cfg)","handlingStrategy":"validation","validationCode":"import importlib.util\nmissing = [m for m in ('pymysql', 'dbutils') if importlib.util.find_spec(m) is None]\nif missing:\n    raise ConfigError(f'azure_mysql requires: {missing} — pip install pymysql dbutils')","typeGuard":null,"tryCatchPattern":"try:\n    from mem0.vector_stores.azure_mysql import AzureMySQL\nexcept ImportError as e:\n    if 'PyMySQL and DBUtils' in str(e):\n        raise ConfigError('pip install pymysql dbutils') from e\n    raise","preventionTips":["Add pymysql and dbutils to requirements when azure_mysql is configured (they are two separate packages)","Test imports in the same venv the app runs in","Rebuild Docker images after adding the dependencies"],"tags":["dependencies","azure","mysql","vector-store","import"],"backgroundTag":null,"analyzedSha":"001c235229be8795e3834520467bd0d661ed8f34","analyzedAt":"2026-08-15T01:55:42.685Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}