psycopg2-pool
Proper pooling of psycopg2 connections
What it is and what it does
psycopg2-pool wraps psycopg2 to provide thread-safe connection pooling for PostgreSQL. Instead of opening and closing a new database connection for each request—an expensive operation—the pool maintains a set of open connections that applications can borrow and return, reducing latency and resource consumption in concurrent workloads.
The package exports a ThreadSafeConnectionPool class that manages a minimum and maximum number of connections, handing them out on demand and recycling them back into the pool. It is designed for multi-threaded Python applications that make frequent database queries and need to amortize connection setup costs. The library depends only on psycopg2-binary and installs as a pure Python wheel.
Use it for:
- Web applications serving concurrent requests that each need a database connection.
- Multi-threaded batch processing jobs that query PostgreSQL repeatedly and need to avoid connection exhaustion.
- Long-running services that spawn worker threads and need a shared, thread-safe pool of database connections.
- Testing frameworks that run parallel test suites against a shared PostgreSQL database.
- Applications requiring reduced connection setup latency in high-concurrency scenarios.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Manages a pool of reusable PostgreSQL connections via psycopg2, reducing connection overhead in multi-threaded applications.
Yes, if you are building a multi-threaded Python application that queries PostgreSQL frequently. The package is simple, has low install friction, carries no known vulnerabilities, and solves a real problem. The dormant maintenance status is a minor concern—monitor for breaking changes in psycopg2 or PostgreSQL—but the code is stable. Be aware of the LGPL3 copyleft license if your application is proprietary.
Install
psycopg2-pool on PyPI
pip
pip install psycopg2-pooluv
uv add psycopg2-poolpoetry
poetry add psycopg2-poolInstalling psycopg2-pool
Before you install
Low friction: pure Python wheel with a single runtime dependency on psycopg2-binary. Maintenance is dormant—last commit was 2024-05-10—but the package is marked Production/Stable.
License in practice
Licensed under LGPL3 (copyleft). Any application that links this library must make its own source code available under a compatible license or comply with LGPL3's linking exceptions.
Quickstart
pip install psycopg2-pool
from psycopg2_pool import ThreadSafeConnectionPool
pool = ThreadSafeConnectionPool(1, 10, "dbname=test user=postgres")
conn = pool.getconn()
# use conn
pool.putconn(conn)
Requires psycopg2-binary installed; application must manage connection lifecycle (getconn/putconn calls).
Verify before relying
- Whether the dormant maintenance status (942 days since latest release) poses a risk for future PostgreSQL or psycopg2 compatibility.
- Performance characteristics and overhead compared to other pooling solutions.
- Specific threading model and concurrency limits of ThreadSafeConnectionPool.
Package facts
| License | LGPL3 (copyleft) |
| Python support | supports the current Python release (>=3.3) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 1 — psycopg2-binary |
| Maintenance | dormant — 942 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 311,370/month — #7,735 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: psycopg2_pool-1.2-py2.py3-none-any.whl
Keywords: postgres, psycopg2
Tags
More Database packages
psycopg2-binary is a PostgreSQL database…
copyleft · top 1,000 on PyPI
redisPython client library for connecting to and…
permissive · top 1,000 on PyPI
ydbYDB Python SDK is the official client library…
permissive · top 1,000 on PyPI
snowflake-connector-pythonConnects Python applications to Snowflake data…
permissive · top 1,000 on PyPI
sqlparsesqlparse tokenizes SQL text into a tree of…
permissive · top 1,000 on PyPI
dbt-adaptersProvides base adapter protocols and shared…
permissive · top 1,000 on PyPI
DBUtilsDBUtils provides pooled, persistent database…
permissive · top 5,000 on PyPI
postgresProvides a lightweight abstraction layer over…
permissive · top 15,000 on PyPI
psycopg-poolProvides a connection pool for Psycopg 3,…
copyleft · top 1,000 on PyPI
queriesQueries is a simplified wrapper around psycopg2…
permissive · top 15,000 on PyPI
pgcopypgcopy wraps PostgreSQL's binary COPY protocol…
permissive · top 15,000 on PyPI
django-db-connection-poolProvides connection pooling for Django database…
permissive · top 15,000 on PyPI
clickhouse-poolProvides a thread-safe connection pool for…
copyleft · top 5,000 on PyPI
django-db-geventpoolProvides a gevent-based connection pool for…
permissive · top 15,000 on PyPI
connection_poolProvides a thread-safe connection pool that…
permissive · top 15,000 on PyPI
psycopg2PostgreSQL database adapter for Python that…
copyleft · top 1,000 on PyPI