Metadata-Version: 2.3
Name: fassung
Version: 0.1.0
Summary: Add your description here
Author: Sergej Morokin
Author-email: Sergej Morokin <sergej.morokin@googlemail.com>
Requires-Dist: asyncpg>=0.30.0
Requires-Dist: asyncpg-stubs>=0.30.2
Requires-Dist: pydantic>=2.12.4
Requires-Python: >=3.14
Description-Content-Type: text/markdown

# Fassung

Fassung combines asyncpg, pydantic and the template strings to provide an ergonomic, type- and SQL-injection-safe interface for working with PostgreSQL databases.

It is currently just a proof of concept and not ready for production use.

## Installation

Fassung requires python 3.14. You can install it with

```bash
pip install fassung
```

or 

```bash
uv add fassung
```

## Usage

Fassung is very similar to asyncpg. The central class is the `Pool` class, which is a context manager for a connection pool. 
You can use the `Pool` class as a context manager to create connections. Each connection can execute queries.

```python
from fassung import Pool
from pydantic import BaseModel


class Student(BaseModel):
    id: int
    name: str
    age: int


async def main():
    pool = Pool()
    async with pool.acquire() as connection:
        async with connection as transaction:
            age = 18
            students: list[Student] = await transaction.fetch(
                Student, t"SELECT * FROM students WHERE age = {age}"
            )
            for student in students:
                print(student.name)
```