This LangChain integration is only supported for Cloud SQL maintenance versions between MYSQL_8_0_36.R20240401.03_00 and MYSQL_8_0_36.R20241208.01_00
Installation
Install this library in a virtualenv using pip. virtualenv is a tool to create isolated Python environments. The basic problem it addresses is
one of dependencies and versions, and indirectly permissions.
With virtualenv, it’s possible to install this library without needing system install permissions, and without clashing with the installed system dependencies.
Contributions to this library are always welcome and highly encouraged.
See CONTRIBUTING for more information how to get started.
Please note that this project is released with a Contributor Code of Conduct. By participating in
this project you agree to abide by its terms. See Code of Conduct for more
information.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-07 UTC."],[],[],null,["Version latestkeyboard_arrow_down\n\n- [0.3.0 (latest)](/python/docs/reference/langchain-google-cloud-sql-mysql/latest)\n- [0.2.3](/python/docs/reference/langchain-google-cloud-sql-mysql/0.2.3) \n\nCloud SQL for MySQL for LangChain\n=================================\n\n[](https://cloud.google.com/products#product-launch-stages) [](https://pypi.org/project/langchain-google-cloud-sql-mysql/) [](https://pypi.org/project/langchain-google-cloud-sql-mysql/)\n\n- [Client Library Documentation](https://cloud.google.com/python/docs/reference/langchain-google-cloud-sql-mysql/latest)\n\n- [Product Documentation](https://cloud.google.com/sql/mysql)\n\nQuick Start\n-----------\n\nIn order to use this library, you first need to go through the following\nsteps:\n\n1. [Select or create a Cloud Platform project.](https://console.cloud.google.com/project)\n\n2. [Enable billing for your project.](https://cloud.google.com/billing/docs/how-to/modify-project#enable_billing_for_a_project)\n\n3. [Enable the Google Cloud SQL Admin API.](https://console.cloud.google.com/flows/enableapi?apiid=sqladmin.googleapis.com)\n\n4. [Setup Authentication.](https://googleapis.dev/python/google-api-core/latest/auth.html)\n\n### Supported Cloud SQL Maintenance Versions\n\nThis LangChain integration is only supported for Cloud SQL maintenance versions between **MYSQL_8_0_36.R20240401.03_00** and **MYSQL_8_0_36.R20241208.01_00**\n\n### Installation\n\nInstall this library in a [virtualenv](https://virtualenv.pypa.io/en/latest/) using pip. [virtualenv](https://virtualenv.pypa.io/en/latest/) is a tool to create isolated Python environments. The basic problem it addresses is\none of dependencies and versions, and indirectly permissions.\n\nWith [virtualenv](https://virtualenv.pypa.io/en/latest/), it's possible to install this library without needing system install permissions, and without clashing with the installed system dependencies.\n\n#### Supported Python Versions\n\nPython \\\u003e= 3.9\n\n#### Mac/Linux\n\n pip install virtualenv\n virtualenv \u003cyour-env\u003e\n source \u003cyour-env\u003e/bin/activate\n \u003cyour-env\u003e/bin/pip install langchain-google-cloud-sql-mysql\n\n#### Windows\n\n pip install virtualenv\n virtualenv \u003cyour-env\u003e\n \u003cyour-env\u003e\\Scripts\\activate\n \u003cyour-env\u003e\\Scripts\\pip.exe install langchain-google-cloud-sql-mysql\n\n### Vector Store Usage\n\nUse a vector store to store embedded data and perform vector search. \n\n from langchain_google_cloud_sql_mysql import MySQLEngine, MySQLVectorStore\n from langchain_google_vertexai import VertexAIEmbeddings\n\n engine = MySQLEngine.from_instance(\"project-id\", \"region\", \"my-instance\", \"my-database\")\n engine.init_vectorstore_table(\n table_name=\"my-table-name\",\n vector_size=768\n )\n vectorstore = MySQLVectorStore(\n engine,\n embedding_service=VertexAIEmbeddings(model_name=\"textembedding-gecko@003\"),\n table_name=\"my-table-name\"\n )\n\nSee the full [Vector Store](https://github.com/googleapis/langchain-google-cloud-sql-mysql-python/blob/main/docs/vector_store.ipynb) tutorial.\n\n### Document Loader Usage\n\nUse a document loader to load data as LangChain `Document`s. \n\n from langchain_google_cloud_sql_mysql import MySQLEngine, MySQLLoader\n\n engine = MySQLEngine.from_instance(\"project-id\", \"region\", \"my-instance\", \"my-database\")\n loader = MySQLLoader(\n engine,\n table_name=\"my-table-name\"\n )\n docs = loader.lazy_load()\n\nSee the full [Document Loader](https://github.com/googleapis/langchain-google-cloud-sql-mysql-python/blob/main/docs/document_loader.ipynb) tutorial.\n\n### Chat Message History Usage\n\nUse `ChatMessageHistory` to store messages and provide conversation\nhistory to LLMs. \n\n from langchain_google_cloud_sql_mysql import MySQLChatMessageHistory, MySQLEngine\n\n engine = MySQLEngine.from_instance(\"project-id\", \"region\", \"my-instance\", \"my-database\")\n history = MySQLChatMessageHistory(\n engine,\n table_name=\"my-message-store\",\n session_id=\"my-session-id\"\n )\n\nSee the full [Chat Message History](https://github.com/googleapis/langchain-google-cloud-sql-mysql-python/blob/main/docs/chat_message_history.ipynb) tutorial.\n\n### Contributions\n\nContributions to this library are always welcome and highly encouraged.\n\nSee [CONTRIBUTING](https://github.com/googleapis/langchain-google-cloud-sql-mysql-python/blob/main/CONTRIBUTING.md) for more information how to get started.\n\nPlease note that this project is released with a Contributor Code of Conduct. By participating in\nthis project you agree to abide by its terms. See [Code of Conduct](https://github.com/googleapis/langchain-google-cloud-sql-mysql-python/blob/main/CODE_OF_CONDUCT.md) for more\ninformation.\n\nLicense\n-------\n\nApache 2.0 - See\n[LICENSE](https://github.com/googleapis/langchain-google-cloud-sql-mysql-python/blob/main/LICENSE)\nfor more information.\n\nDisclaimer\n----------\n\nThis is not an officially supported Google product."]]