Psycopg

The modern PostgreSQL adapter for Python, with native async and pipeline support

Library
PyPI
v3.3.4
2,473stars
LGPL-3.0

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
82/100Excellent
Development Activity100
Maintenance52
Community76
Maturity60
Momentum40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
83/100Excellent
Architecture85
Code Quality88
Innovation82
Learning Curve75

Psycopg 3 is a complete rewrite of the classic psycopg2 PostgreSQL driver, built around asyncio-native connections and cursors, a C-optimized libpq binding, and strict static typing. It ships as a small family of packages (the pure-Python core, an optional Cython speedup module, and a separate connection-pool package) so applications can pull in exactly the runtime they need.

It is the driver of choice for modern async Python web stacks (FastAPI, Django async views, aiohttp) that need first-class PostgreSQL support without falling back to thread pools, while still supporting fully synchronous usage for traditional codebases.

What You Get

  • Synchronous and native asyncio connection/cursor classes sharing one API surface
  • libpq pipeline mode support for batching multiple queries over one round trip
  • An optional C/Cython extension (psycopg_c) for CPU-bound adaptation hot paths
  • A separate psycopg_pool package with sync and async connection pools
  • Server-side (named) cursors, COPY support, and typed row factories (dict, namedtuple, dataclass)
  • Full type adaptation system mapping PostgreSQL types (including arrays, ranges, JSON) to Python objects

Common Use Cases

  • Powering async web frameworks (FastAPI, Starlette, async Django) that talk to PostgreSQL without blocking the event loop
  • High-throughput services that need pipeline mode to cut round-trip latency on batched writes
  • Migrating psycopg2 codebases to a maintained, actively developed driver with modern typing
  • Applications needing precise control over server-side cursors and COPY for bulk data transfer

Under The Hood

Architecture: The repository is organized as three cooperating packages — psycopg/psycopg (pure-Python core defining Connection/AsyncConnection, Cursor/AsyncCursor, and the adaptation layer in _transformer.py/_adapters_map.py), psycopg_c (a Cython-compiled libpq binding for performance), and psycopg_pool (kept as a separately-released package so pooling can iterate on its own cadence). Connections communicate with PostgreSQL via generator-based state machines (generators.py, waiting.py) that let the same code drive both blocking sockets and asyncio event loops, which is how sync and async cursors share nearly identical implementations. Tech Stack: Python 3.9+, Cython/C for the optional binary extension, libpq as the underlying client library, pytest for testing, mypy --strict for type-checking across all three sub-packages. Code Quality: The tests/ directory contains 70+ test modules covering connections, cursors (sync/async/server-side/raw), COPY, pipelines, transactions, type adaptation, DNS/SRV resolution, and CockroachDB compatibility (tests/crdb/), with mirrored _async variants generated from shared fixtures to keep sync/async behavior in lockstep; mypy strict = true is enforced project-wide via pre-commit hooks. API Design: The public API deliberately follows PEP 249 (DB-API 2.0) conventions extended with async with/async for support, row factories for typed results, and context-manager-based transactions, so developers already familiar with psycopg2 or other DBAPI drivers have very little new surface to learn.

Used by 29 apps in this directory

Python
66%
Apache 2.0

Agent Control

AI Agents

295

An open-source runtime control plane for AI agents — define safety guardrails once, apply them across agents built on LangChain, CrewAI, Google ADK, or AWS Strands, and update controls without redeploying code.

View details
79
Repo Health
71
Technical
70
Dependency
Built with
Python66%
TypeScript33%
Updated yesterday
Python
100%
Apache 2.0

Agno

Devops · AI Development · Automation

41,774

Build, run, and manage agent platforms with a full production stack — SDK, runtime, and control plane included.

View details
93
Repo Health
87
Technical
67
Dependency
Built with
Python100%
Updated today
Python
90%
Apache 2.0

Apache Airflow

Data Engineering

46,530

Define, schedule, and monitor complex data workflows as Python code — with a powerful UI, 80+ provider integrations, and battle-tested scalability across thousands of production deployments.

View details
96
Repo Health
89
Technical
66
Dependency
Built with
Python90%
Updated today
Python
54%
Other

authentik

Authentication · Security

24,980

The self-hosted Identity Provider that replaces Okta, Auth0, and Entra ID with a unified SSO platform supporting SAML, OAuth2/OIDC, LDAP, RADIUS, and WebAuthn.

View details
92
Repo Health
81
Technical
68
Dependency
Built with
Python54%
TypeScript33%
Updated today
Python
62%
MIT

AutoGen

AI Development · Automation

60,518

Build autonomous and human-in-the-loop multi-agent AI systems with a layered, event-driven Python and .NET framework pioneered at Microsoft Research.

View details
57
Repo Health
78
Technical
75
Dependency
Built with
Python62%
C#25%
TypeScript12%
Updated 4 months ago
C++
69%
Apache 2.0

ClickHouse

Databases · Analytics · Data Engineering

49,325

Open-source column-oriented database that delivers real-time analytical queries on petabyte-scale data with millisecond latency.

View details
95
Repo Health
90
Technical
68
Dependency
Built with
C++69%
Python13%
Updated today
Python
51%
MIT

Docs

File Storage · CMS

16,733

Open-source collaborative knowledge platform with real-time editing, AI writing tools, and full self-hosting control — built by the French and German governments.

View details
87
Repo Health
81
Technical
72
Dependency
Built with
Python51%
TypeScript42%
Updated 2 days ago
TypeScript
40%
MIT

FeatBit

Devops · Developer Tools

1,902

Self-hosted, enterprise-grade feature flag platform for safe, targeted, and data-driven feature releases.

View details
89
Repo Health
78
Technical
70
Dependency
Built with
TypeScript40%
C#37%
Updated today
Python
100%
MIT

Graphify

AI Agents

108,063

A YC-backed, open-source knowledge graph skill for AI coding assistants — type /graphify and it maps your entire project (code, docs, PDFs, images, videos) into a queryable graph instead of grepping through files.

View details
82
Repo Health
73
Technical
78
Dependency
Built with
Python100%
Updated 2 days ago

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search