PostgresLoader(
key: object,
engine: langchain_google_cloud_sql_pg.engine.PostgresEngine,
query: str,
content_columns: typing.List[str],
metadata_columns: typing.List[str],
formatter: typing.Callable,
metadata_json_column: typing.Optional[str] = None,
)
Load documents from PostgreSQL`.
Each document represents one row of the result. The content_columns
are
written into the content_columns
of the document. The metadata_columns
are written
into the metadata_columns
of the document. By default, first columns is written into
the page_content
and everything else into the metadata
.
Methods
PostgresLoader
PostgresLoader(
key: object,
engine: langchain_google_cloud_sql_pg.engine.PostgresEngine,
query: str,
content_columns: typing.List[str],
metadata_columns: typing.List[str],
formatter: typing.Callable,
metadata_json_column: typing.Optional[str] = None,
)
PostgresLoader constructor.
Parameters | |
---|---|
Name | Description |
key |
object
Prevent direct constructor usage. |
engine |
PostgresEngine
AsyncEngine with pool connection to the postgres database |
query |
Optional[str], optional
SQL query. Defaults to None. |
content_columns |
Optional[List[str]], optional
Column that represent a Document's page_content. Defaults to the first column. |
metadata_columns |
Optional[List[str]], optional
Column(s) that represent a Document's metadata. Defaults to None. |
formatter |
Optional[Callable], optional
A function to format page content (OneOf: format, formatter). Defaults to None. |
metadata_json_column |
Optional[str], optional
Column to store metadata as JSON. Defaults to "langchain_metadata". |
Exceptions | |
---|---|
Type | Description |
Exception |
If called directly by user. |
_collect_async_items
_collect_async_items(docs_generator)
Exhause document generator into a list.
alazy_load
alazy_load() -> typing.AsyncIterator[langchain_core.documents.base.Document]
Load PostgreSQL data into Document objects lazily.
aload
aload() -> typing.List[langchain_core.documents.base.Document]
Load PostgreSQL data into Document objects.
create
create(
engine: langchain_google_cloud_sql_pg.engine.PostgresEngine,
query: typing.Optional[str] = None,
table_name: typing.Optional[str] = None,
schema_name: str = "public",
content_columns: typing.Optional[typing.List[str]] = None,
metadata_columns: typing.Optional[typing.List[str]] = None,
metadata_json_column: typing.Optional[str] = None,
format: typing.Optional[str] = None,
formatter: typing.Optional[typing.Callable] = None,
) -> langchain_google_cloud_sql_pg.loader.PostgresLoader
Create a new PostgresLoader instance.
Parameters | |
---|---|
Name | Description |
engine |
PostgresEngine
AsyncEngine with pool connection to the postgres database |
query |
Optional[str], optional
SQL query. Defaults to None. |
table_name |
Optional[str], optional
Name of table to query. Defaults to None. |
schema_name |
str, optional
Database schema name of the table. Defaults to "public". |
content_columns |
Optional[List[str]], optional
Column that represent a Document's page_content. Defaults to the first column. |
metadata_columns |
Optional[List[str]], optional
Column(s) that represent a Document's metadata. Defaults to None. |
metadata_json_column |
Optional[str], optional
Column to store metadata as JSON. Defaults to "langchain_metadata". |
format |
Optional[str], optional
Format of page content (OneOf: text, csv, YAML, JSON). Defaults to 'text'. |
formatter |
Optional[Callable], optional
A function to format page content (OneOf: format, formatter). Defaults to None. |
create_sync
create_sync(
engine: langchain_google_cloud_sql_pg.engine.PostgresEngine,
query: typing.Optional[str] = None,
table_name: typing.Optional[str] = None,
schema_name: str = "public",
content_columns: typing.Optional[typing.List[str]] = None,
metadata_columns: typing.Optional[typing.List[str]] = None,
metadata_json_column: typing.Optional[str] = None,
format: typing.Optional[str] = None,
formatter: typing.Optional[typing.Callable] = None,
) -> langchain_google_cloud_sql_pg.loader.PostgresLoader
Create a new PostgresLoader instance.
Parameters | |
---|---|
Name | Description |
engine |
PostgresEngine
AsyncEngine with pool connection to the postgres database |
query |
Optional[str], optional
SQL query. Defaults to None. |
table_name |
Optional[str], optional
Name of table to query. Defaults to None. |
schema_name |
str, optional
Database schema name of the table. Defaults to "public". |
content_columns |
Optional[List[str]], optional
Column that represent a Document's page_content. Defaults to the first column. |
metadata_columns |
Optional[List[str]], optional
Column(s) that represent a Document's metadata. Defaults to None. |
metadata_json_column |
Optional[str], optional
Column to store metadata as JSON. Defaults to "langchain_metadata". |
format |
Optional[str], optional
Format of page content (OneOf: text, csv, YAML, JSON). Defaults to 'text'. |
formatter |
Optional[Callable], optional
A function to format page content (OneOf: format, formatter). Defaults to None. |
lazy_load
lazy_load() -> typing.Iterator[langchain_core.documents.base.Document]
Load PostgreSQL data into Document objects lazily.
load
load() -> typing.List[langchain_core.documents.base.Document]
Load PostgreSQL data into Document objects.