finds.dev← search

// the find

psycopg/psycopg2

★ 3,641 · C · NOASSERTION · updated May 2026

PostgreSQL database adapter for the Python programming language

psycopg2 is the standard PostgreSQL adapter for Python — a C extension wrapping libpq that implements DB-API 2.0. It has been the default choice for Python/Postgres work for well over a decade, and it still is for anyone on an existing codebase. New projects should use psycopg3 instead; the README says so explicitly.

The C implementation means parameter binding and result fetching are fast and memory-efficient compared to pure-Python alternatives. Thread safety is genuine — multiple threads can share a single connection safely, which matters for threaded web workers. COPY TO/COPY FROM support is first-class, making bulk loads practical without round-tripping through INSERT. The type adaptation system handles arrays, ranges, JSON, hstore, and UUID out of the box, with a clean extension point for custom types.

No async support worth using — the 'asynchronous' mode predates asyncio and is incompatible with it; you cannot use this with asyncpg-style async/await code. The binary wheel (`psycopg2-binary`) bundles its own libpq, which causes subtle conflicts when the system also has libpq installed at a different version — production installs require a compiler, which is a real friction point in containerized builds. The project is explicitly in maintenance mode with no new features planned, so anything Postgres has shipped in the last few years (pipeline mode, more COPY improvements) you won't see here. Connection pooling in `lib/pool.py` is a minimal thread-based implementation that doesn't scale well and most teams replace it with PgBouncer or a separate library anyway.

View on GitHub → Homepage ↗

// want more like this?

We dig through GitHub every week and send a few repos picked for what you actually care about — each with an honest take like this one.

Get finds in your inbox → Search again →