langchain-postgres
An integration package connecting Postgres and LangChain
Decision gist · record as of 2026-08-14
Yes. The package is actively maintained, has low install friction, carries no known vulnerabilities, and is licensed permissively. It fills a clear role for developers building LangChain applications that need persistent vector storage or chat history in PostgreSQL. Install it if you are already using LangChain and need a Postgres-backed vector store or session manager; skip it if you do not use LangChain or prefer a different database backend.AI-flagged interpretation of the facts on this page — verify before relying
Before you install
- Requires a running PostgreSQL instance and either asyncpg or psycopg driver installed; Python 3.9 or later.
- Low friction installation with a pure-Python wheel.
- Actively maintained as of the latest release.
License · maintenance · safety
MIT (permissive) — Released under the MIT license (permissive), allowing free use, modification, and distribution with minimal restrictions.
last release 2026-02-17 (178 days)
0 known vulnerabilities (OSV.dev, 2026-08-14) · 1,578,491 downloads/mo, #3,743 on PyPI
Alternatives
Verify before relying
pip install langchain-postgres
from langchain_postgres import PGEngine, PGVectorStore
from langchain_core.embeddings import DeterministicFakeEmbedding
engine = PGEngine.from_connection_string("postgresql+psycopg://user:pass@localhost/db")
embedding = DeterministicFakeEmbedding(size=768)
store = PGVectorStore.create_sync(engine=engine, table_name="docs", embedding_service=embedding)
store.add_documents([...])
results = store.similarity_search("query")- Performance characteristics of hybrid search compared to vector-only search in production workloads.
- Whether the migration path from deprecated PGVector to PGVectorStore is straightforward for large existing datasets.
What it is and what it does
langchain-postgres bridges LangChain and PostgreSQL, providing implementations of core LangChain abstractions (vector stores, chat message history, document storage) that persist data in a Postgres database. It supports both synchronous and asynchronous workflows and offers two driver options: asyncpg and psycopg3.
The package's main components are PGVectorStore for semantic search with optional hybrid search (combining vector and keyword matching), and PostgresChatMessageHistory for persisting conversation state across sessions. Both are designed to be used directly or extended for custom applications. The package depends on sqlalchemy for ORM operations, pgvector for vector operations, and numpy for numerical work.
Use it for
- Build a RAG (retrieval-augmented generation) application that stores document embeddings in Postgres and retrieves relevant context for LLM prompts.
- Persist multi-turn chat conversations in a database so users can resume sessions or audit interaction history.
- Implement hybrid search combining semantic similarity and keyword matching to improve retrieval relevance.
- Deploy LangChain applications on cloud-hosted Postgres (AlloyDB, Cloud SQL) with simplified connection management.
- Extend the provided abstractions to add custom metadata filtering or schema changes for domain-specific requirements.
Worth the install?
AI-flagged interpretation of the facts on this page. Verify before relying on it.
Yes.
The package is actively maintained, has low install friction, carries no known vulnerabilities, and is licensed permissively. It fills a clear role for developers building LangChain applications that need persistent vector storage or chat history in PostgreSQL. Install it if you are already using LangChain and need a Postgres-backed vector store or session manager; skip it if you do not use LangChain or prefer a different database backend.
Install
langchain-postgres on PyPI
Before you install
Low friction installation with a pure-Python wheel. Actively maintained as of the latest release. Requires PostgreSQL and one of two supported drivers (asyncpg or psycopg3), which are listed as runtime dependencies.
Requires a running PostgreSQL instance and either asyncpg or psycopg driver installed; Python 3.9 or later.
License in practice
Released under the MIT license (permissive), allowing free use, modification, and distribution with minimal restrictions.
Quickstart
pip install langchain-postgres
from langchain_postgres import PGEngine, PGVectorStore
from langchain_core.embeddings import DeterministicFakeEmbedding
engine = PGEngine.from_connection_string("postgresql+psycopg://user:pass@localhost/db")
embedding = DeterministicFakeEmbedding(size=768)
store = PGVectorStore.create_sync(engine=engine, table_name="docs", embedding_service=embedding)
store.add_documents([...])
results = store.similarity_search("query")
Verify before relying
- Performance characteristics of hybrid search compared to vector-only search in production workloads.
- Whether the migration path from deprecated PGVector to PGVectorStore is straightforward for large existing datasets.
Package facts
| License | MIT permissive |
| Python support | Supports the current Python release >=3.9 |
| Install friction | Low. Pure-Python wheel |
| Runtime dependencies | 7 packagesasyncpglangchain-corenumpypgvectorpsycopg-poolpsycopgsqlalchemy |
| Maintenance | Actively maintained 178 days since the last release |
| First released | |
| Downloads | 1,578,491 / month, #3,743 on PyPI 30-day window, as of 2026-08-14 |
| Known vulnerabilities | None known OSV.dev, checked 2026-08-14 |
Evidence: langchain_postgres-0.0.17-py3-none-any.whl
Tags
Let your AI agent find packages like this
Example. Real query, live index.
You found this page by searching. An agent finds it by wishing: SkillFed indexes 14,416 PyPI packages by what they can do, searchable in plain language.
wish › “langchain postgres integration”
- langchain-postgresProvides LangChain abstractions for vector storage, chat history, and…
- langchain-xaiConnects xAI's language models to LangChain applications through…
- testcontainers-postgresProvides a PostgreSQL Docker container wrapper for integration and…
Give your agent the search over MCP, or paste the wish link into any chat.
More Database packages
psycopg2-binary is a PostgreSQL database adapter for Python that implements the DB API 2.0 specification, enabling Python applications to connect to and query PostgreSQL databases with thread-safe concurrent operations.
Python client library for connecting to and executing commands against Redis key-value stores, supporting both synchronous and asynchronous operations.
Install it if your application needs to interact with Redis; the only prerequisite is a running Redis server instance.
YDB Python SDK is the official client library for connecting to and querying YDB databases from Python applications.
Install it if you need to connect Python applications to YDB databases.
Connects Python applications to Snowflake data warehouses using the DB API 2.0 specification, enabling SQL queries, data transfers, and warehouse operations.
sqlparse tokenizes SQL text into a tree of statements, clauses, and expressions, and provides functions to split scripts, format queries, and inspect parsed tokens without validating dialect or syntax.
Install it if you need to manipulate, format, or analyze SQL text programmatically.
Provides base adapter protocols and shared functionality that database adapters use to integrate with dbt-core, handling connections, dialect translation, relation caching, and core interface management.
See also langchain-astradb · llama-index-vector-stores-postgres · langchain-pinecone · langchain-qdrant · langchain-elasticsearch · langchain-milvus · langchain-chroma · langchain-google-vertexai · langchain-neo4j · langgraph-checkpoint-aws