Skip to content

Latest commit

 

History

History
73 lines (46 loc) · 2.24 KB

File metadata and controls

73 lines (46 loc) · 2.24 KB

AirPostgres

PyPI version PyPI downloads

PostgreSQL persistence for air.AirModel.

Air keeps model definitions and the async CRUD API in core. AirPostgres provides the PostgreSQL-specific pieces: asyncpg pooling, SQL generation, transactions, and table creation.

Features

  • Async CRUD and backend-neutral query lookups for AirModel classes
  • Asyncpg pool lifecycle and transaction management
  • Idempotent table creation with non-destructive column additions
  • Typed support for Python 3.13 and newer

Installation

uv add AirPostgres

Usage

from contextlib import asynccontextmanager

import air
from airpostgres import AirPostgres


class Note(air.AirModel):
    id: int | None = air.AirField(default=None, primary_key=True)
    body: str


database = AirPostgres()


@asynccontextmanager
async def lifespan(app):
    async with database.lifespan("postgresql://localhost/example")(app):
        await database.create_tables()
        yield


app = air.Air(lifespan=lifespan)

Application models import only from air. Replacing AirPostgres with another backend, such as AirD1, does not change those model definitions.

Documentation

Full documentation is available on GitHub Pages.

Contributing

See CONTRIBUTING.md for development setup, testing, and documentation instructions.

Author

AirPostgres was created in 2026 by Audrey M. Roy Greenfeld and Daniel Roy Greenfeld.

Built with Cookiecutter and the audreyfeldroy/cookiecutter-pypackage project template.