psycopg
The most popular PostgreSQL adapter for Python
A complete implementation of the Python DB API 2.0 specification, built on top of the official PostgreSQL client library, with many extensions giving access to the full power of modern Python and PostgreSQL.
sponsors
Psycopg is free software. If you use Python and PostgreSQL and would like to support the maintenance of the most advanced adapter between the two systems, please consider becoming a sponsor. Sponsoring helps ensure the continued maintenance of Psycopg 2, Psycopg 3, and related projects.
features
Psycopg 3 is the current generation. It keeps full DB-API 2.0 compatibility while adding native asyncio, server-side binding, pipeline mode, and a much more powerful connection pool.
| Psycopg 3 | Psycopg 2 |
|---|---|
| Python 3.10–3.14 | Python 3.9–3.14 |
| PostgreSQL 10–18 | PostgreSQL 7.4–18 |
| Native asyncio support | Low-level async only |
| Server- and client-side parameter binding | Client-side binding only |
| Automatic prepared statements | No prepared statemetns support |
| Pipeline / batch mode | No pipeline mode support |
| Advanced connection pool | Very basic connection pool |
| Static typing support | No static typing support |
| Async COPY support | Synchronous COPY only |
development
Note: there is no psycopg3 package - the current generation ships as
psycopg. The [binary] extra bundles a pre-compiled C extension so no PostgreSQL
client libraries need to be installed separately.
Psycopg 2 remains fully supported for legacy applications. New projects should use Psycopg 3.
Both packages are available on PyPI and install with a single pip command. Source distributions are also available for environments that require compilation from source.
articles
Read more!Automatic Async to Sync Code Conversion
Daniele Varrazzo
Daniele is the creator and primary maintainer of psycopg2 and psycopg3. He has been working on PostgreSQL database connectivity for Python for over fifteen years.
His work on the DB-API 2.0 specification, binary protocol support, and asyncio integration has made psycopg the standard choice for Python developers working with PostgreSQL.
Support the project via GitHub Sponsors.
maintainers
contact
Follow the Psycopg team