--- id: psycopg2-pool version: "1.2" license: LGPL3 license_treatment: copyleft maintenance: dormant --- # psycopg2-pool — Proper pooling of psycopg2 connections License: copyleft · Maintenance: dormant · Downloads: 311.4K/mo ## 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 above — 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 pip install psycopg2-pool uv add psycopg2-pool poetry add psycopg2-pool ## Installing 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_current - Install friction: low - Maintenance: dormant - Downloads: 311.4K/month (top 15,000 on PyPI) - Known vulnerabilities: none known ## Tags psycopg2 connection pooling, postgresql connection pool, thread-safe database connections, reuse postgres connections, connection pool management, psycopg2 thread pool, database connection caching, connection-pooling, postgresql, concurrency [View on SkillFed](https://skillfed.io/packages/psycopg2-pool) · [View on PyPI](https://pypi.org/project/psycopg2-pool/)