PostgresEngine(
engine: sqlalchemy.ext.asyncio.engine.AsyncEngine,
loop: typing.Optional[asyncio.events.AbstractEventLoop],
thread: typing.Optional[threading.Thread],
)
A class for managing connections to a Cloud SQL for Postgres database.
Methods
_aexecute
_aexecute(query: str, params: typing.Optional[dict] = None)
Execute a SQL query.
_aexecute_outside_tx
_aexecute_outside_tx(query: str)
Execute a SQL query.
_aload_table_schema
_aload_table_schema(table_name: str) -> sqlalchemy.sql.schema.Table
Load table schema from existing table in PgSQL database.
Returns | |
---|---|
Type | Description |
(sqlalchemy.Table) |
The loaded table. |
ainit_document_table
ainit_document_table(
table_name: str,
content_column: str = "page_content",
metadata_columns: typing.List[langchain_google_cloud_sql_pg.engine.Column] = [],
metadata_json_column: str = "langchain_metadata",
store_metadata: bool = True,
) -> None
Create a table for saving of langchain documents.
Parameters | |
---|---|
Name | Description |
table_name |
str
The PgSQL database table name. |
metadata_columns |
List[sqlalchemy.Column]
A list of SQLAlchemy Columns to create for custom metadata. Optional. |
store_metadata |
bool
Whether to store extra metadata in a metadata column if not described in 'metadata' field list (Default: True). |
ainit_vectorstore_table
ainit_vectorstore_table(
table_name: str,
vector_size: int,
content_column: str = "content",
embedding_column: str = "embedding",
metadata_columns: typing.List[langchain_google_cloud_sql_pg.engine.Column] = [],
metadata_json_column: str = "langchain_metadata",
id_column: str = "langchain_id",
overwrite_existing: bool = False,
store_metadata: bool = True,
) -> None
Create a table for saving of vectors to be used with PostgresVectorStore.
Parameters | |
---|---|
Name | Description |
table_name |
str
The Postgres database table name. |
vector_size |
int
Vector size for the embedding model to be used. |
content_column |
str
Name of the column to store document content. Default: "page_content". |
embedding_column |
str
Name of the column to store vector embeddings. Default: "embedding". |
metadata_columns |
List[Column]
A list of Columns to create for custom metadata. Default: []. Optional. |
metadata_json_column |
str
The column to store extra metadata in JSON format. Default: "langchain_metadata". Optional. |
id_column |
str
Name of the column to store ids. Default: "langchain_id". Optional, |
overwrite_existing |
bool
Whether to drop existing table. Default: False. |
store_metadata |
bool
Whether to store metadata in the table. Default: True. |