TiDB Cloud, is a comprehensive Database-as-a-Service (DBaaS) solution, that provides dedicated and serverless options. TiDB Serverless is now integrating a built-in vector search into the MySQL landscape. With this enhancement, you can seamlessly develop AI applications using TiDB Serverless without the need for a new database or additional technical stacks. Be among the first to experience it by joining the waitlist for the private beta at tidb.cloud/ai.This notebook introduces how to use
TiDBLoader
to load data from TiDB in langchain.
Prerequisites
Before using theTiDBLoader
, we will install the following dependencies:
Load Data from TiDB
Here’s a breakdown of some key arguments you can use to customize the behavior of theTiDBLoader
:
-
query
(str): This is the SQL query to be executed against the TiDB database. The query should select the data you want to load into yourDocument
objects. For instance, you might use a query like"SELECT * FROM my_table"
to fetch all data frommy_table
. -
page_content_columns
(Optional[List[str]]): Specifies the list of column names whose values should be included in thepage_content
of eachDocument
object. If set toNone
(the default), all columns returned by the query are included inpage_content
. This allows you to tailor the content of each document based on specific columns of your data. -
metadata_columns
(Optional[List[str]]): Specifies the list of column names whose values should be included in themetadata
of eachDocument
object. By default, this list is empty, meaning no metadata will be included unless explicitly specified. This is useful for including additional information about each document that doesn’t form part of the main content but is still valuable for processing or analysis.