[PR #138] Add support to specify custom table schema #186

Open
opened 2026-02-16 05:16:53 -05:00 by yindo · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/langchain-ai/langchain-postgres/pull/138
Author: @anupkg1985
Created: 11/10/2024
Status: 🔄 Open

Base: mainHead: main


📝 Commits (4)

  • 5da6c24 Add support to specify custom table schema
  • 4c05345 Merge branch 'main' into main
  • a232cbf Merge branch 'main' into main
  • 7d8c729 Merge branch 'main' into main

📊 Changes

1 file changed (+11 additions, -5 deletions)

View changed files

📝 langchain_postgres/vectorstores.py (+11 -5)

📄 Description

Current LangChain-Postgres framework, the database table name is hardcoded and defaults to the public schema due to the absence of a specified schema name. This limitation affects the flexibility of the PGVector connector, restricting its ability to dynamically configure during runtime. This poses significant challenges in multi-tenant architectures, where it's essential for different clients or projects to operate within separate schemas to ensure data isolation and management efficiency. Addressing this issue would involve enabling schema specification, thereby enhancing the connector's versatility and making it more suitable for diverse deployment scenarios.

Proposed solution -

  • Introduced new argument/ parameter table_schema to `PGVector' class
  • This new parameter is optional and defaulted to public schema

Discussions related to issue -
https://github.com/langchain-ai/langchain/discussions/20877
https://github.com/langchain-ai/langchain/discussions/18883

Example usage -

Default publicschema -

connection = "postgresql+psycopg://langchain:langchain@localhost:6024/langchain" 
collection_name = "my_docs"
embeddings = CohereEmbeddings()

vectorstore = PGVector(
    embeddings=embeddings,
    collection_name=collection_name,
    connection=connection,
    use_jsonb=True,
)

Specify custom table-schema -

connection = "postgresql+psycopg://langchain:langchain@localhost:6024/langchain" 
collection_name = "my_docs"
embeddings = CohereEmbeddings()

vectorstore = PGVector(
    embeddings=embeddings,
    collection_name=collection_name,
    connection=connection,
    use_jsonb=True,
    table_schema="custom"
)

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/langchain-ai/langchain-postgres/pull/138 **Author:** [@anupkg1985](https://github.com/anupkg1985) **Created:** 11/10/2024 **Status:** 🔄 Open **Base:** `main` ← **Head:** `main` --- ### 📝 Commits (4) - [`5da6c24`](https://github.com/langchain-ai/langchain-postgres/commit/5da6c24fa325df19afb6ab3896d404944fe86b0a) Add support to specify custom table schema - [`4c05345`](https://github.com/langchain-ai/langchain-postgres/commit/4c05345b6880e4ffc8820b4d5726b4eb46c6fa8d) Merge branch 'main' into main - [`a232cbf`](https://github.com/langchain-ai/langchain-postgres/commit/a232cbff6493d547daaceddec413e24a9299f084) Merge branch 'main' into main - [`7d8c729`](https://github.com/langchain-ai/langchain-postgres/commit/7d8c7292e258afa1a4176670edb4d8c90964d44d) Merge branch 'main' into main ### 📊 Changes **1 file changed** (+11 additions, -5 deletions) <details> <summary>View changed files</summary> 📝 `langchain_postgres/vectorstores.py` (+11 -5) </details> ### 📄 Description Current `LangChain-Postgres` framework, the database table name is hardcoded and defaults to the `public` schema due to the absence of a specified schema name. This limitation affects the flexibility of the `PGVector` connector, restricting its ability to dynamically configure during runtime. This poses significant challenges in multi-tenant architectures, where it's essential for different clients or projects to operate within separate schemas to ensure data isolation and management efficiency. Addressing this issue would involve enabling schema specification, thereby enhancing the connector's versatility and making it more suitable for diverse deployment scenarios. Proposed solution - - Introduced new argument/ parameter `table_schema` to `PGVector' class - This new parameter is optional and defaulted to `public` schema Discussions related to issue - https://github.com/langchain-ai/langchain/discussions/20877 https://github.com/langchain-ai/langchain/discussions/18883 Example usage - Default `public`schema - ``` connection = "postgresql+psycopg://langchain:langchain@localhost:6024/langchain" collection_name = "my_docs" embeddings = CohereEmbeddings() vectorstore = PGVector( embeddings=embeddings, collection_name=collection_name, connection=connection, use_jsonb=True, ) ``` Specify custom table-schema - ``` connection = "postgresql+psycopg://langchain:langchain@localhost:6024/langchain" collection_name = "my_docs" embeddings = CohereEmbeddings() vectorstore = PGVector( embeddings=embeddings, collection_name=collection_name, connection=connection, use_jsonb=True, table_schema="custom" ) ``` --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
yindo added the pull-request label 2026-02-16 05:16:53 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langchain-ai/langchain-postgres#186