Metadata-Version: 2.4
Name: flaxon-postsql
Version: 0.1.0
Summary: Async PostgreSQL connection-pool integration for Flaxon
Author: Aldane Hutchinson
License: MIT
Project-URL: Repository, https://github.com/aldanedev-create/flaxon-postsql
Project-URL: Issues, https://github.com/aldanedev-create/flaxon-postsql/issues
Classifier: Development Status :: 5 - Production/Stable
Classifier: Framework :: AsyncIO
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Database
Requires-Python: >=3.11
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: asyncpg>=0.29
Requires-Dist: flaxon>=0.2.0
Provides-Extra: dev
Requires-Dist: pytest>=8; extra == "dev"
Dynamic: license-file

# Flaxon PostSQL

`flaxon-postsql` is a lightweight PostgreSQL wrapper built on `asyncpg`. It
owns an async connection pool and exposes it as `app.state.postsql`.

## Install

```bash
pip install flaxon-postsql
```

## Use

```python
import os

from flaxon import Flaxon
from flaxon_postsql import PostSQLPlugin

app = Flaxon("catalog")
await app.plugins.load_plugin(PostSQLPlugin(os.environ["DATABASE_URL"], min_size=2, max_size=10))


@app.get("/products")
async def list_products():
    rows = await app.state.postsql.fetch("SELECT id, name FROM products ORDER BY id")
    return {"products": [dict(row) for row in rows]}
```

The connection pool opens during application startup and closes during
shutdown. Always use positional `$1`, `$2`, … parameters with `asyncpg`; do
not build SQL with string interpolation. Store the database URL in a secret
manager or environment variable.

This project is named `postsql` at the package level but integrates with
PostgreSQL through `asyncpg`.
