OSS TanbouSign in with GitHub

connect Python services to PostgreSQL with synchronous and asynchronous APIs

OSS scale score 220.7OSS health 100
About these scores

OSS scale score is an unbounded metric that log-compresses and weights Stars, Watchers, Forks, and Contributors. Discovery score is the current OSS scale score minus the score at discovery. Update pace is commits in the last 30 days, growth momentum is the OSS scale score difference within the recent observation window, and OSS health is a 0–100 rating based on available recency, Community Health, and release data.

Stars
2,504
Primary language
Python
License
LGPL-3.0-only
Repository last updated
Oct 2, 2026
On this page

Overview

Psycopg 3 is a PostgreSQL adapter for Python. It provides synchronous and asynchronous connections, cursors, transactions, and PostgreSQL type adaptation, with a pure-Python implementation plus optional binary and C implementations. Connection pooling is distributed separately.

Features and best fit

Based on official documentation; not hands-on tested · Content checked:

Key features

Use synchronous and asynchronous PostgreSQL connections with parallel API concepts

psycopg.connect() provides synchronous connections while AsyncConnection.connect() supports asynchronous applications. Context managers manage commit or rollback behavior and connection closure, and the project also documents gevent integration.

Sources: [4][5]

Choose pure Python, binary, or C implementations and add pooling separately

The main package includes a pure-Python implementation, the binary extra installs a prebuilt implementation, and the c extra adds the C extension. Connection pools live in the separate psycopg-pool package with synchronous and asynchronous lifecycle management.

Sources: [2][3][6]

Best fit

Fits Python backends that want explicit PostgreSQL driver and transaction control

Psycopg can sit underneath an ORM or be used directly by SQL-oriented services. It fits synchronous web applications, asynchronous services, and batch workloads that need explicit control over PostgreSQL connections and transactions.

Sources: [2][4][5]

Before adoption

Psycopg 3.3.6 requires Python 3.10+; verify implementation and libpq requirements per deployment

Psycopg 3.3.6 requires Python 3.10 or newer. The pure-Python, binary, and C installation modes have different libpq and build characteristics. Version 3.3.6 adds Python 3.15 support, reduces async query overhead, and avoids indefinite waits after query interruption; part of the interrupt fix requires libpq 17 or newer.

Sources: [3][7]

Official sources

  1. [1]psycopg/psycopg — GitHub repository(2026-10-06)
  2. [2]Psycopg 3.3.6 — README(2026-10-06)
  3. [3]Psycopg 3.3.6 — package metadata(2026-10-06)
  4. [4]Psycopg 3.3.6 — basic usage(2026-10-06)
  5. [5]Psycopg 3.3.6 — concurrent operations(2026-10-06)
  6. [6]Psycopg 3.3.6 — connection pools(2026-10-06)
  7. [7]Psycopg 3.3.6 release notes(2026-10-06)
  8. [8]Psycopg LGPL-3.0-only license(2026-10-06)
Supplemental curator note

Psycopg exposes the PostgreSQL driver layer directly, making it useful when transactions, connections, and type adaptation should not be hidden behind an ORM. Choose pure Python, binary, or C installation and whether pooling belongs in the application or an external pooler per deployment.

Try it in 3 steps

  1. 1

    Install the Psycopg 3.3.6 binary implementation

    Pin the reviewed Psycopg release. Python 3.10 or newer is required.

    python -m pip install "psycopg[binary]==3.3.6"
  2. 2

    Set a disposable PostgreSQL connection string

    Replace USER, PASSWORD, HOST, and DBNAME with a PostgreSQL database that is safe to use for verification. Do not commit real credentials.

    export DATABASE_URL='postgresql://USER:PASSWORD@HOST:5432/DBNAME'
  3. 3

    Connect and read the server version

    Use a read-only SELECT to verify connectivity and query execution without changing database schema or data.

    python - <<'PY' import os import psycopg with psycopg.connect(os.environ['DATABASE_URL']) as conn: print(conn.execute('select version()').fetchone()[0]) PY
Check the official README

Growth

Growth trends · Last 30 days

2,504 Stars

Trend data is still being collected.

Built with

Categories and tags

GitHub data

GitHub dataView detailed GitHub data

GitHub Topics

  • database
  • development
  • driver
  • postgresql
  • python
Stars
2,504
Forks
283
Watchers
28
Open issues
64
Contributors
103
Owner type
Organization
Primary language
Python
Repository last updated
Oct 2, 2026
Write a related article

Share a guide or use case for this OSS in Markdown. Articles are published after administrator approval.

Report incorrect information

Tell us if any listing information is incorrect or outdated.

After reading this page, do you know what to do next?