Skip to main content

pronto-pg

Async PostgreSQL connection pool helper for FastAPI (and any async Python) projects. Wraps psycopg3 with a module-level pool and a ready-made FastAPI lifespan hook.

Installation

pip install pronto-pg

Quick start — FastAPI

from fastapi import FastAPI
from pronto_pg.v1 import make_lifespan, get_connection

app = FastAPI(lifespan=make_lifespan("DATABASE_URL"))

@app.get("/users")
async def list_users():
    async with get_connection() as conn:
        rows = await conn.execute("SELECT id, email FROM users")
        return await rows.fetchall()

Set your DSN in the environment (e.g. via .env + python-dotenv):

DATABASE_URL=postgresql://user:pass@host:5432/mydb

Pass any env var name to make_lifespan — PG_DATABASE_URL, MY_DATABASE_URL, whatever fits your project.

API

make_lifespan(env_var="DATABASE_URL", min_size=2, max_size=10)

Returns a FastAPI-compatible lifespan context manager. Opens the pool on startup, closes it on shutdown.

app = FastAPI(lifespan=make_lifespan("PG_DATABASE_URL"))

init_pool(dsn, min_size=2, max_size=10)

Open the pool with an explicit DSN string.

init_pool_from_env(env_var="DATABASE_URL", min_size=2, max_size=10)

Open the pool by reading the DSN from an environment variable. Raises RuntimeError if the variable is missing or empty.

close_pool()

Drain and close the pool. Called automatically by make_lifespan.

get_connection()

Async context manager that yields a psycopg.AsyncConnection in autocommit mode. Use async with conn.transaction(): for explicit transactions.

async with get_connection() as conn:
    await conn.execute("INSERT INTO events (type) VALUES (%s)", ["login"])

Manual lifespan (without make_lifespan)

from contextlib import asynccontextmanager
from fastapi import FastAPI
from pronto_pg.v1 import init_pool_from_env, close_pool

@asynccontextmanager
async def lifespan(app):
    await init_pool_from_env("DATABASE_URL")
    yield
    await close_pool()

app = FastAPI(lifespan=lifespan)

Development

pip install -e ".[dev]"
pytest

Versioning

Versions are derived from git tags via hatch-vcs.

git tag v0.1.0
hatch build

Metadata

Release files for pronto-pg 0.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pronto-pg 0.0.1
File Size Uploaded Provenance
pronto_pg-0.0.1.tar.gz 9.7 kB With provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for pronto-pg 0.0.1
File Interpreter ABI Platform
pronto_pg-0.0.1-py3-none-any.whl Python 3 none any Details

Total release size: 15.2 kB

Release files / pronto_pg-0.0.1.tar.gz

Download URL pronto_pg-0.0.1.tar.gz
Size 9.7 kB
Tags Source
SHA-256 checksum
How to use checksums
34bdcc00f3a6735b71d3b13bc74d105135185b2b8b0bfe65f3c9dca73619df89
BLAKE2b-256 checksum
How to use checksums
9b7a1aea35f01a1184bd5ca9539238de2f343fb23ae1d891bf03fd547d0d2ecc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on May 24, 2026.

Transparency log

Release files / pronto_pg-0.0.1-py3-none-any.whl

Download URL pronto_pg-0.0.1-py3-none-any.whl
Size 5.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4a42315d850d06b1ffcfe768857392baf43d5f0c6c2c99efd9bad392d2e50ab5
BLAKE2b-256 checksum
How to use checksums
92af9ce9fa85df6f388f0428c8f4ffc89739e1ab07f1af06b5bcb40f08937461
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on May 24, 2026.

Transparency log

Security for pronto-pg 0.0.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for pronto_pg-0.0.1.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on May 24, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.0.1 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page