Class PostgresReader (0.2.1)

PostgresReader(
    key: object,
    engine: PostgresEngine,
    reader: AsyncPostgresReader,
    is_remote: bool = True,
)

Chat Store Table stored in an Cloud SQL for PostgreSQL database.

Methods

PostgresReader

PostgresReader(
    key: object,
    engine: PostgresEngine,
    reader: AsyncPostgresReader,
    is_remote: bool = True,
)

PostgresReader constructor.

Parameters
Name Description
key object

Prevent direct constructor usage.

engine PostgresEngine

PostgresEngine with pool connection to the Cloud SQL postgres database

reader AsyncPostgresReader

The async only PostgresReader implementation

is_remote Optional[bool]

Whether the data is loaded from a remote API or a local file.

Exceptions
Type Description
Exception If called directly by user.

alazy_load_data

alazy_load_data() -> typing.AsyncIterable[llama_index.core.schema.Document]

Asynchronously load Cloud SQL postgres data into Document objects lazily.

aload_data

aload_data() -> list[llama_index.core.schema.Document]

Asynchronously load Cloud SQL postgres data into Document objects.

class_name

class_name() -> str

Get class name.

create

create(
    engine: llama_index_cloud_sql_pg.engine.PostgresEngine,
    query: typing.Optional[str] = None,
    table_name: typing.Optional[str] = None,
    schema_name: str = "public",
    content_columns: typing.Optional[list[str]] = None,
    metadata_columns: typing.Optional[list[str]] = None,
    metadata_json_column: typing.Optional[str] = None,
    format: typing.Optional[str] = None,
    formatter: typing.Optional[typing.Callable] = None,
    is_remote: bool = True,
) -> llama_index_cloud_sql_pg.reader.PostgresReader

Asynchronously create an PostgresReader instance.

Parameters
Name Description
engine PostgresEngine

PostgresEngine with pool connection to the Cloud SQL 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

Name of the schema where table is located. 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 "li_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.

is_remote Optional[bool]

Whether the data is loaded from a remote API or a local file.

Returns
Type Description
PostgresReader A newly created instance of PostgresReader.

create_sync

create_sync(
    engine: llama_index_cloud_sql_pg.engine.PostgresEngine,
    query: typing.Optional[str] = None,
    table_name: typing.Optional[str] = None,
    schema_name: str = "public",
    content_columns: typing.Optional[list[str]] = None,
    metadata_columns: typing.Optional[list[str]] = None,
    metadata_json_column: typing.Optional[str] = None,
    format: typing.Optional[str] = None,
    formatter: typing.Optional[typing.Callable] = None,
    is_remote: bool = True,
) -> llama_index_cloud_sql_pg.reader.PostgresReader

Synchronously create an PostgresReader instance.

Parameters
Name Description
engine PostgresEngine

PostgresEngine with pool connection to the Cloud SQL 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

Name of the schema where table is located. 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 "li_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.

is_remote Optional[bool]

Whether the data is loaded from a remote API or a local file.

Returns
Type Description
PostgresReader A newly created instance of PostgresReader.

lazy_load_data

lazy_load_data() -> typing.Iterable[llama_index.core.schema.Document]

Synchronously load Cloud SQL postgres data into Document objects lazily.

load_data

load_data() -> list[llama_index.core.schema.Document]

Synchronously load Cloud SQL postgres data into Document objects.

model_post_init

model_post_init(context: Any, /) -> None

This function is meant to behave like a BaseModel method to initialise private attributes.

It takes context as an argument since that's what pydantic-core passes when calling it.