MSSQLDocumentSaver(
engine: langchain_google_cloud_sql_mssql.engine.MSSQLEngine,
table_name: str,
content_column: typing.Optional[str] = None,
metadata_json_column: typing.Optional[str] = None,
)
A class for saving langchain documents into a Cloud SQL MSSQL database table.
Methods
MSSQLDocumentSaver
MSSQLDocumentSaver(
engine: langchain_google_cloud_sql_mssql.engine.MSSQLEngine,
table_name: str,
content_column: typing.Optional[str] = None,
metadata_json_column: typing.Optional[str] = None,
)
MSSQLDocumentSaver 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 |
MSSQLEngine
MSSQLEngine object to connect to the MSSQL database. |
table_name |
str
The name of table for saving documents. |
content_column |
str
The column to store document content. Deafult: |
metadata_json_column |
str
The name of the JSON column to use as the metadata’s base dictionary. Default: |
add_documents
add_documents(docs: typing.List[langchain_core.documents.base.Document]) -> None
Save documents in the DocumentSaver table. Document’s metadata is added to columns if found or stored in langchain_metadata JSON column.
Parameter | |
---|---|
Name | Description |
docs |
List[langchain_core.documents.Document]
a list of documents to be saved. |
delete
delete(docs: typing.List[langchain_core.documents.base.Document]) -> None
Delete all instances of a document from the DocumentSaver table by matching the entire Document object.
Parameter | |
---|---|
Name | Description |
docs |
List[langchain_core.documents.Document]
a list of documents to be deleted. |