psqlpy

raw JSON →
0.11.12 verified Sat May 09 auth: no python

psqlpy is an async PostgreSQL driver for Python written in Rust, offering high performance and full async/await support. Current version is 0.11.12, with active development and regular releases.

pip install psqlpy
error TypeError: 'coroutine' object is not subscriptable
cause Missing await on async function call.
fix
Add await before the call, e.g., await pool.execute('SELECT 1')
error ImportError: cannot import name 'ConnectionPool' from 'psqlpy'
cause ConnectionPool renamed to AsyncPool in version 0.10.0.
fix
Use 'from psqlpy import AsyncPool'
error psqlpy.exceptions.PoolError: Pool is closed
cause Attempting to use the pool after it has been closed.
fix
Ensure pool is still open before queries; use context manager to handle lifecycle.
breaking Renamed ConnectionPool to AsyncPool in 0.10.0; old name no longer works.
fix Use from psqlpy import AsyncPool instead.
gotcha Pool must be explicitly closed or used as async context manager to avoid hanging connections.
fix Use 'async with pool' or ensure pool.close() is called after use.
gotcha All queries must be awaited; forgetting await returns a coroutine object, not results.
fix Always 'await pool.execute(...)' or 'await conn.fetch(...)'.
pip install psqlpy[uvloop]

Basic async query using connection pool.

import asyncio
import os
from psqlpy import AsyncPool

async def main():
    pool = AsyncPool(
        dsn=os.environ.get("DATABASE_URL", "postgresql://user:pass@localhost/db"),
        max_size=10
    )
    result = await pool.execute("SELECT 1")
    print(result)
    await pool.close()

asyncio.run(main())