langchain_community.document_loaders.tidb.TiDBLoader

class langchain_community.document_loaders.tidb.TiDBLoader(connection_string: str, query: str, page_content_columns: Optional[List[str]] = None, metadata_columns: Optional[List[str]] = None, engine_args: Optional[Dict[str, Any]] = None)[source]

Load documents from TiDB.

Initialize TiDB document loader.

Parameters
  • connection_string (str) – The connection string for the TiDB database, format: “mysql+pymysql://root@127.0.0.1:4000/test”.

  • query (str) – The query to run in TiDB.

  • page_content_columns (Optional[List[str]]) – Optional. Columns written to Document page_content, default(None) to all columns.

  • metadata_columns (Optional[List[str]]) – Optional. Columns written to Document metadata, default(None) to no columns.

  • engine_args (Optional[Dict[str, Any]]) – Optional. Additional arguments to pass to sqlalchemy engine.

Methods

__init__(connection_string, query[, ...])

Initialize TiDB document loader.

alazy_load()

A lazy loader for Documents.

lazy_load()

Lazy load TiDB data into document objects.

load()

Load data into Document objects.

load_and_split([text_splitter])

Load Documents and split into chunks.

__init__(connection_string: str, query: str, page_content_columns: Optional[List[str]] = None, metadata_columns: Optional[List[str]] = None, engine_args: Optional[Dict[str, Any]] = None) None[source]

Initialize TiDB document loader.

Parameters
  • connection_string (str) – The connection string for the TiDB database, format: “mysql+pymysql://root@127.0.0.1:4000/test”.

  • query (str) – The query to run in TiDB.

  • page_content_columns (Optional[List[str]]) – Optional. Columns written to Document page_content, default(None) to all columns.

  • metadata_columns (Optional[List[str]]) – Optional. Columns written to Document metadata, default(None) to no columns.

  • engine_args (Optional[Dict[str, Any]]) – Optional. Additional arguments to pass to sqlalchemy engine.

Return type

None

async alazy_load() AsyncIterator[Document]

A lazy loader for Documents.

Return type

AsyncIterator[Document]

lazy_load() Iterator[Document][source]

Lazy load TiDB data into document objects.

Return type

Iterator[Document]

load() List[Document]

Load data into Document objects.

Return type

List[Document]

load_and_split(text_splitter: Optional[TextSplitter] = None) List[Document]

Load Documents and split into chunks. Chunks are returned as Documents.

Do not override this method. It should be considered to be deprecated!

Parameters

text_splitter (Optional[TextSplitter]) – TextSplitter instance to use for splitting documents. Defaults to RecursiveCharacterTextSplitter.

Returns

List of Documents.

Return type

List[Document]