MySQLDocumentSaver allows for saving of langchain documents in a database. If the table
doesn't exists, a table with default schema will be created. The default schema:
page_content (type: text)
langchain_metadata (type: JSON)
Parameters
Name
Description
engine
MySQLEngine
MySQLEngine object to connect to the MySQL database.
table_name
str
The name of table for saving documents.
content_column
str
The column to store document content. Deafult: page_content. Optional.
metadata_json_column
str
The name of the JSON column to use as the metadata’s base dictionary. Default: langchain_metadata. Optional.
[[["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,["# Class MySQLDocumentSaver (0.3.0)\n\nVersion latestkeyboard_arrow_down\n\n- [0.3.0 (latest)](/python/docs/reference/langchain-google-cloud-sql-mysql/latest/langchain_google_cloud_sql_mysql.loader.MySQLDocumentSaver)\n- [0.2.3](/python/docs/reference/langchain-google-cloud-sql-mysql/0.2.3/langchain_google_cloud_sql_mysql.loader.MySQLDocumentSaver) \n\n MySQLDocumentSaver(\n engine: langchain_google_cloud_sql_mysql.engine.MySQLEngine,\n table_name: str,\n content_column: typing.Optional[str] = None,\n metadata_json_column: typing.Optional[str] = None,\n )\n\nA class for saving langchain documents into a Cloud SQL MySQL database table.\n\nMethods\n-------\n\n### MySQLDocumentSaver\n\n MySQLDocumentSaver(\n engine: langchain_google_cloud_sql_mysql.engine.MySQLEngine,\n table_name: str,\n content_column: typing.Optional[str] = None,\n metadata_json_column: typing.Optional[str] = None,\n )\n\nMySQLDocumentSaver allows for saving of langchain documents in a database. If the table\ndoesn't exists, a table with default schema will be created. The default schema:\n\n- page_content (type: text)\n- langchain_metadata (type: JSON)\n\n### add_documents\n\n add_documents(docs: typing.List[langchain_core.documents.base.Document]) -\u003e None\n\nSave documents in the DocumentSaver table. Document's metadata is added to columns if found or\nstored in langchain_metadata JSON column.\n\n### delete\n\n delete(docs: typing.List[langchain_core.documents.base.Document]) -\u003e None\n\nDelete all instances of a document from the DocumentSaver table by matching the entire Document\nobject."]]