TiDBLoader#

class langchain_community.document_loaders.tidb.TiDBLoader(connection_string: str, query: str, page_content_columns: List[str] | None = None, metadata_columns: List[str] | None = None, engine_args: Dict[str, Any] | None = 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 (List[str] | None) – Optional. Columns written to Document page_content, default(None) to all columns.

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

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

Methods

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

Initialize TiDB document loader.

alazy_load()

A lazy loader for Documents.

aload()

Load data into Document objects.

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: List[str] | None = None, metadata_columns: List[str] | None = None, engine_args: Dict[str, Any] | None = 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 (List[str] | None) – Optional. Columns written to Document page_content, default(None) to all columns.

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

  • engine_args (Dict[str, Any] | None) – 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]

async aload() β†’ List[Document]#

Load data into Document objects.

Return type:

List[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: TextSplitter | None = 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]

Examples using TiDBLoader