Class MySQLLoader (0.2.3)

MySQLLoader(
    engine: langchain_google_cloud_sql_mysql.engine.MySQLEngine,
    table_name: str = "",
    query: str = "",
    content_columns: typing.Optional[typing.List[str]] = None,
    metadata_columns: typing.Optional[typing.List[str]] = None,
    metadata_json_column: typing.Optional[str] = None,
)

A class for loading langchain documents from a Cloud SQL MySQL database.

Methods

MySQLLoader

MySQLLoader(
    engine: langchain_google_cloud_sql_mysql.engine.MySQLEngine,
    table_name: str = "",
    query: str = "",
    content_columns: typing.Optional[typing.List[str]] = None,
    metadata_columns: typing.Optional[typing.List[str]] = None,
    metadata_json_column: typing.Optional[str] = None,
)

Document page content defaults to the first column present in the query or table and metadata defaults to all other columns. Use with content_columns to overwrite the column used for page content. Use metadata_columns to select specific metadata columns rather than using all remaining columns.

If multiple content columns are specified, page_content’s string format will default to space-separated string concatenation.

Parameters
Name Description
engine MySQLEngine

MySQLEngine object to connect to the MySQL database.

table_name str

The MySQL database table name. (OneOf: table_name, query).

query str

The query to execute in MySQL format. (OneOf: table_name, query).

content_columns List[str]

The columns to write into the page_content of the document. Optional.

metadata_columns List[str]

The columns to write into the metadata of the document. Optional.

metadata_json_column str

The name of the JSON column to use as the metadata’s base dictionary. Default: langchain_metadata. Optional.

lazy_load

lazy_load() -> typing.Iterator[langchain_core.documents.base.Document]

Lazy Load langchain documents from a Cloud SQL MySQL database. Use lazy load to avoid caching all documents in memory at once.

Returns
Type Description
(Iterator[langchain_core.documents.Document]) a list of Documents with metadata from specific columns.

load

load() -> typing.List[langchain_core.documents.base.Document]

Load langchain documents from a Cloud SQL MySQL database.

Returns
Type Description
(List[langchain_core.documents.Document]) a list of Documents with metadata from specific columns.