asyncpg
An asyncio PostgreSQL driver
Decision gist · record as of 2026-08-14
Yes. asyncpg is production-stable (Development Status 5), actively maintained, has no known vulnerabilities, and is the standard choice for async PostgreSQL access in Python. Install friction is moderate but manageable via pre-built wheels. Use it whenever you need non-blocking PostgreSQL queries in an asyncio application.AI-flagged interpretation of the facts on this page — verify before relying
Before you install
- Requires Python 3.9 or later and a running PostgreSQL server (versions 9.5 to 18 actively tested).
- asyncpg is a compiled extension; pre-built wheels are available for common platforms.
- Medium install friction due to compiled C extensions across multiple platforms (wheels provided for CPython 3.9–3.14 on macOS, Linux, and Windows).
License · maintenance · safety
Apache-2.0 (permissive) — Apache 2.0 is permissive; you can use asyncpg in commercial and proprietary projects with minimal restrictions, provided you include a copy of the license and note material changes.
last release 2025-11-24 (263 days) · last repo commit 2026-02-27 · 8,065 stars
0 known vulnerabilities (OSV.dev, 2026-08-14) · 115,073,622 downloads/mo, #309 on PyPI
Alternatives
Verify before relying
import asyncio
import asyncpg
async def example():
conn = await asyncpg.connect(user='user', password='password',
database='database', host='127.0.0.1')
rows = await conn.fetch('SELECT * FROM mytable WHERE id = $1', 10)
await conn.close()
asyncio.run(example())- Whether the stated 5x performance advantage over psycopg3 holds for your specific workload and query patterns.
- Support status for PostgreSQL versions outside the 9.5–18 range and non-PostgreSQL databases claiming protocol compatibility.
What it is and what it does
asyncpg is a PostgreSQL client library built from the ground up for Python's asyncio framework. Unlike generic database adapters, it implements the PostgreSQL binary protocol natively, exposing protocol features directly rather than hiding them behind a DB-API facade. This design enables efficient, non-blocking database operations in async applications.
The library supports prepared statements, scrollable cursors, partial result iteration, and automatic encoding/decoding of composite types and arrays. It has one runtime dependency (async_timeout) and is distributed under Apache 2.0. The project is actively maintained, with wheels available for Python 3.9–3.14 across macOS, Linux, and Windows platforms.
Use it for
- Building high-concurrency web services (e.g., FastAPI or Starlette apps) that need to query PostgreSQL without blocking the event loop.
- Streaming large result sets from PostgreSQL without loading them entirely into memory using partial iteration.
- Applications requiring prepared statements or custom PostgreSQL data types with automatic encoding/decoding.
- Real-time data pipelines or event-driven systems that benefit from async/await syntax for database operations.
- Microservices or async workers that handle many concurrent database connections efficiently.
Worth the install?
AI-flagged interpretation of the facts on this page. Verify before relying on it.
Yes.
asyncpg is production-stable (Development Status 5), actively maintained, has no known vulnerabilities, and is the standard choice for async PostgreSQL access in Python. Install friction is moderate but manageable via pre-built wheels. Use it whenever you need non-blocking PostgreSQL queries in an asyncio application.
Install
asyncpg on PyPI
Before you install
Medium install friction due to compiled C extensions across multiple platforms (wheels provided for CPython 3.9–3.14 on macOS, Linux, and Windows). Maintenance is active with recent releases; last commit 2026-02-27 and 263 days since latest release indicate steady upkeep.
Requires Python 3.9 or later and a running PostgreSQL server (versions 9.5 to 18 actively tested). asyncpg is a compiled extension; pre-built wheels are available for common platforms.
License in practice
Apache 2.0 is permissive; you can use asyncpg in commercial and proprietary projects with minimal restrictions, provided you include a copy of the license and note material changes.
Quickstart
import asyncio
import asyncpg
async def example():
conn = await asyncpg.connect(user='user', password='password',
database='database', host='127.0.0.1')
rows = await conn.fetch('SELECT * FROM mytable WHERE id = $1', 10)
await conn.close()
asyncio.run(example())
Verify before relying
- Whether the stated 5x performance advantage over psycopg3 holds for your specific workload and query patterns.
- Support status for PostgreSQL versions outside the 9.5–18 range and non-PostgreSQL databases claiming protocol compatibility.
Package facts
| License | Apache-2.0 permissive |
| Python support | Supports the current Python release >=3.9.0 |
| Install friction | Medium. Platform-specific wheel |
| Runtime dependencies | 1 packageasync_timeout |
| Maintenance | Actively maintained 263 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 115,073,622 / month, #309 on PyPI 30-day window, as of 2026-08-14 |
| Known vulnerabilities | None known OSV.dev, checked 2026-08-14 |
| Classifiers | Development Status :: 5 - Production/StableFramework :: AsyncIOIntended Audience :: DevelopersOperating System :: MacOS :: MacOS XOperating System :: Microsoft :: WindowsOperating System :: POSIXProgramming Language :: Python :: 3 :: OnlyProgramming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.14Programming Language :: Python :: 3.9Programming Language :: Python :: Free Threading :: 2 - BetaProgramming Language :: Python :: Implementation :: CPythonTopic :: Database :: Front-Ends |
Evidence: asyncpg-0.31.0-cp310-cp310-macosx_10_9_x86_64.whl; asyncpg-0.31.0-cp310-cp310-macosx_11_0_arm64.whl; asyncpg-0.31.0-cp310-cp310-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl; asyncpg-0.31.0-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl; asyncpg-0.31.0-cp310-cp310-musllinux_1_2_aarch64.whl; asyncpg-0.31.0-cp310-cp310-musllinux_1_2_x86_64.whl; asyncpg-0.31.0-cp310-cp310-win32.whl; asyncpg-0.31.0-cp310-cp310-win_amd64.whl; asyncpg-0.31.0-cp311-cp311-macosx_10_9_x86_64.whl; asyncpg-0.31.0-cp311-cp311-macosx_11_0_arm64.whl; asyncpg-0.31.0-cp311-cp311-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl; asyncpg-0.31.0-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl; asyncpg-0.31.0-cp311-cp311-musllinux_1_2_aarch64.whl; asyncpg-0.31.0-cp311-cp311-musllinux_1_2_x86_64.whl; asyncpg-0.31.0-cp311-cp311-win32.whl; asyncpg-0.31.0-cp311-cp311-win_amd64.whl; asyncpg-0.31.0-cp312-cp312-macosx_10_13_x86_64.whl; asyncpg-0.31.0-cp312-cp312-macosx_11_0_arm64.whl; asyncpg-0.31.0-cp312-cp312-manylinux_2_28_aarch64.whl; asyncpg-0.31.0-cp312-cp312-manylinux_2_28_x86_64.whl
Tags
Let your AI agent find packages like this
Example. Real query, live index.
You found this page by searching. An agent finds it by wishing: SkillFed indexes 14,416 PyPI packages by what they can do, searchable in plain language.
wish › “async postgresql driver”
- asyncpgasyncpg is an asyncio-native PostgreSQL client library that executes…
- aiopgaiopg provides asyncio-based access to PostgreSQL databases, wrapping…
- sqlalchemy-jdbcapiSQLAlchemy dialect for JDBC and ODBC database connections with…
Give your agent the search over MCP, or paste the wish link into any chat.
More Front-Ends packages
SQLAlchemy is a Python SQL toolkit and Object Relational Mapper (ORM) that provides both a high-level ORM layer for declarative object persistence and a Core SQL construction system for direct database abstraction and query building.
psycopg2-binary is a PostgreSQL database adapter for Python that implements the DB API 2.0 specification, enabling Python applications to connect to and query PostgreSQL databases with thread-safe concurrent operations.
Alembic generates and manages database schema migrations for SQLAlchemy applications, handling version control of database structure changes with support for upgrades, downgrades, and auto-generation from model changes.
Install it if you use SQLAlchemy and need to version-control schema changes; skip it only if you manage migrations manually or use a different ORM entirely.
A Python client library for connecting to and querying Weaviate, a vector database that enables semantic search and AI-powered data retrieval.
A Python client library that connects to Databricks clusters and SQL warehouses using a Thrift-based protocol, conforming to the Python DB API 2.0 specification and supporting Arrow-based data exchange.
Install it if you need to query Databricks clusters or SQL warehouses from Python.
Psycopg 3 is a PostgreSQL database adapter for Python that enables applications to connect to, query, and manage PostgreSQL databases using Python code.
Install it if you need to connect Python to PostgreSQL.
See also asyncpg-trek · buildpg · opentelemetry-instrumentation-asyncpg · asyncpg-stubs · databases · pgqueuer · asyncmy · pysqlsync