Google Cloud SQL for MySQL
Cloud SQL is a fully managed relational database service that offers high performance, seamless integration, and impressive scalability. It offers PostgreSQL, MySQL, and SQL Server database engines. Extend your database application to build AI-powered experiences leveraging Cloud SQL's LangChain integrations.
This notebook goes over how to use Cloud SQL for MySQL
to store vector embeddings with the MySQLVectorStore
class.
Learn more about the package on GitHub.
Before you begin
To run this notebook, you will need to do the following:
- Create a Google Cloud Project
- Enable the Cloud SQL Admin API.
- Create a Cloud SQL instance. (version must be >= 8.0.36 with cloudsql_vector database flag configured to "On")
- Create a Cloud SQL database.
- Add a User to the database.
🦜🔗 Library Installation
Install the integration library, langchain-google-cloud-sql-mysql
, and the library for the embedding service, langchain-google-vertexai
.
%pip install --upgrade --quiet langchain-google-cloud-sql-mysql langchain-google-vertexai
Colab only: Uncomment the following cell to restart the kernel or use the button to restart the kernel. For Vertex AI Workbench you can restart the terminal using the button on top.
# # Automatically restart kernel after installs so that your environment can access the new packages
# import IPython
# app = IPython.Application.instance()
# app.kernel.do_shutdown(True)
🔐 Authentication
Authenticate to Google Cloud as the IAM user logged into this notebook in order to access your Google Cloud Project.
- If you are using Colab to run this notebook, use the cell below and continue.
- If you are using Vertex AI Workbench, check out the setup instructions here.
from google.colab import auth
auth.authenticate_user()