skillfed

aiopg

Postgres integration with asyncio.

aiopg v1.4.0 634.7K downloads/30d#5,643 on PyPI1,432
Permissive license BSD AGING released

What it is and what it does

aiopg is an asyncio driver for PostgreSQL that wraps psycopg2's synchronous interface to provide non-blocking database access. It lets you execute queries, manage transactions, and maintain connection pools without blocking the event loop—essential for async web frameworks and concurrent applications that need to query PostgreSQL.

The library supports both raw SQL execution via cursors and optional SQLAlchemy integration for ORM-style queries. It handles connection pooling, transaction management, and cursor operations asynchronously. Two runtime dependencies—psycopg2-binary and async-timeout—provide the underlying database driver and timeout handling.

Use it for:

  • Build async web services (FastAPI, aiohttp) that query PostgreSQL without blocking I/O.
  • Implement concurrent batch processing where multiple coroutines execute database queries in parallel.
  • Use SQLAlchemy ORM asynchronously by leveraging aiopg.sa for schema-driven database operations.
  • Manage connection pools efficiently in long-running async applications to avoid resource exhaustion.
  • Write async database migrations or data pipelines that process large datasets without halting the event loop.

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

aiopg provides asyncio-based access to PostgreSQL databases, wrapping psycopg2 to enable non-blocking queries and connection pooling in async Python applications.

Yes, with conditions. aiopg is stable and production-ready for async PostgreSQL access, with low install friction and no known vulnerabilities. However, the aging maintenance status (last release October 2022) means it may lag behind recent PostgreSQL or asyncio changes. Install it if you need async PostgreSQL support in an existing codebase or stable async framework; evaluate alternatives if you require cutting-edge PostgreSQL features or are starting a new project where ongoing maintenance is critical.

Install

aiopg on PyPI

pip

pip install aiopg

uv

uv add aiopg

poetry

poetry add aiopg

Installing aiopg

Before you install

Low install friction with a pure-wheel distribution. Maintenance status is aging—last release was 2022-10-26 (1388 days ago)—but the repository remains active and unarchived. The package supports current Python versions (3.7–3.11) and has a stable production classifier.

License in practice

BSD permissive license places no restrictions on use, modification, or distribution in proprietary or open-source projects.

Quickstart

import asyncio
import aiopg

async def query():
    pool = await aiopg.create_pool('dbname=mydb user=user password=pass host=localhost')
    async with pool.acquire() as conn:
        async with conn.cursor() as cur:
            await cur.execute('SELECT 1')
            async for row in cur:
                print(row)

asyncio.run(query())

Requires a running PostgreSQL server and psycopg2-binary (C extension) to be installed; psycopg2-binary must compile or a pre-built wheel must be available for your platform.

Verify before relying

  • Whether the aging maintenance status (1388 days since last release) affects compatibility with recent PostgreSQL versions or asyncio changes.
  • Current state of SQLAlchemy integration support given the 1.4.x compatibility fixes in the changelog but no recent releases.

Package facts

License BSD (permissive)
Python support supports the current Python release (>=3.7)
Install friction low — pure-Python wheel
Runtime dependencies 2 — psycopg2-binary, async-timeout
Maintenance aging — 1,388 days since the last release
Last repo commit
First released
Downloads 634,709/month — #5,643 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: aiopg-1.4.0-py3-none-any.whl

Development Status :: 5 - Production/StableEnvironment :: Web EnvironmentFramework :: AsyncIOIntended Audience :: DevelopersLicense :: OSI Approved :: BSD LicenseOperating System :: MacOS :: MacOS XOperating System :: Microsoft :: WindowsOperating System :: POSIXProgramming Language :: Python :: 3Programming Language :: Python :: 3 :: OnlyProgramming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.7Programming Language :: Python :: 3.8Programming Language :: Python :: 3.9Topic :: DatabaseTopic :: Database :: Front-Ends

Tags

async postgres driverasyncio postgresql clientnon-blocking database accessasync connection poolingpsycopg2 async wrapperasyncio database libraryasync sql execution
async-databasepostgresconnection-pooling

More Database packages