Skip to main content
Volcengine RDS for MySQL is a fully managed, stable, and scalable relational database service developed by Volcano Engine(Volcengine). Volcengine is a cloud service platform developed by ByteDance, the parent company of TikTok. This integration allows you to use RDS for MySQL as a vector store in LangChain.

Setup

To use the Volcengine MySQL vector store, you’ll need a Volcengine account and an RDS for MySQL instance.

Installation

Install the integration package:
pip
pip install -U langchain-volcengine-mysql

Instantiation

Configure the mysql submodule, then access mysql.vector_store.
from langchain_volcengine_mysql import mysql
from langchain_openai import OpenAIEmbeddings

embeddings = OpenAIEmbeddings()

mysql.configure(
    host="your-mysql-host.example.com",
    port=3306,
    user="your_user",
    password="your_password",
    database="your_db",
    table_name="langchain_vectors",
    embedding_function=embeddings,
)

vector_store = mysql.vector_store
retriever = mysql.retriever

Manage vector store

Add items

from langchain_core.documents import Document

docs = [
    Document(page_content="Volcengine RDS for MySQL is a managed relational database.", metadata={"source": "docs"}),
    Document(page_content="You can use it as a LangChain vector store.", metadata={"source": "docs"}),
]

vector_store.add_documents(documents=docs, ids=["1", "2"])

Delete items

vector_store.delete(ids=["2"])

Query vector store

results = vector_store.similarity_search(query="What is RDS for MySQL?", k=1)
for doc in results:
    print(f"* {doc.page_content} [{doc.metadata}]")

Use as a retriever

docs = retriever.invoke("What is RDS for MySQL?")

API reference

See the official PyPI docs.
Connect these docs to Claude, VSCode, and more via MCP for real-time answers.