Class SpannerDocumentSaver (0.4.1)

SpannerDocumentSaver(
    instance_id: str,
    database_id: str,
    table_name: str,
    content_column: str = "page_content",
    metadata_columns: typing.List[str] = [],
    metadata_json_column: str = "langchain_metadata",
    primary_key: typing.Optional[str] = None,
    client: typing.Optional[google.cloud.spanner_v1.client.Client] = None,
)

Save docs to Google Cloud Spanner.

Methods

SpannerDocumentSaver

SpannerDocumentSaver(
    instance_id: str,
    database_id: str,
    table_name: str,
    content_column: str = "page_content",
    metadata_columns: typing.List[str] = [],
    metadata_json_column: str = "langchain_metadata",
    primary_key: typing.Optional[str] = None,
    client: typing.Optional[google.cloud.spanner_v1.client.Client] = None,
)

Initialize Spanner document saver.

add_documents

add_documents(documents: typing.List[langchain_core.documents.base.Document])

Add documents to the Spanner table.

create_table

create_table(
    client: google.cloud.spanner_v1.client.Client,
    instance_id: str,
    database_id: str,
    table_name: str,
    primary_key: str,
    metadata_json_column: str,
    content_column: str,
    metadata_columns: typing.List[langchain_google_spanner.loader.Column],
)

Create a new table in Spanner database.

delete

delete(documents: typing.List[langchain_core.documents.base.Document])

Delete documents from the table.

init_document_table

init_document_table(
    instance_id: str,
    database_id: str,
    table_name: str,
    content_column: str = "page_content",
    metadata_columns: typing.List[langchain_google_spanner.loader.Column] = [],
    primary_key: str = "",
    store_metadata: bool = True,
    metadata_json_column: str = "langchain_metadata",
)

Create a new table to store docs with a custom schema.