Metadata-Version: 2.4
Name: fastasyncpg
Version: 0.1.0
Summary: A simple wrapper for asyncpg
Author-email: Jeremy Howard <github@jhoward.fastmail.fm>
License: Apache-2.0
Project-URL: Repository, https://github.com/AnswerDotAI/fastasyncpg
Project-URL: Documentation, https://AnswerDotAI.github.io/fastasyncpg/
Keywords: nbdev
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Requires-Python: >=3.11
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: asyncpg
Requires-Dist: fastcore
Requires-Dist: sqlparse
Provides-Extra: dev
Requires-Dist: ipykernel_helper>=0.0.58; extra == "dev"
Dynamic: license-file

# fastasyncpg


<!-- WARNING: THIS FILE WAS AUTOGENERATED! DO NOT EDIT! -->

## Installation

Install latest from [pypi](https://pypi.org/project/fastasyncpg/)

``` sh
$ pip install fastasyncpg
```

## How to use

Create one
[`Database`](https://AnswerDotAI.github.io/fastasyncpg/core.html#database)
at import time, and connect it at app startup:

``` python
from fastasyncpg.core import Database

db = Database()          # module-level singleton, importable everywhere

async def startup(): await db.connect(database='mydb')
```

Queries run through the pool by default. `transaction` (and `acquire`)
make a single connection *current for the running task* via a
`ContextVar`, so everything inside the block – including table helpers
and code called indirectly – joins the transaction, with no
handle-passing:

``` python
async with db.transaction():
    await db.execute('SELECT 1 FROM "user" WHERE id=$1 FOR UPDATE', uid)
    await db.t.user.update(pk_values=[uid], credits=100)
```

See the [API docs](https://AnswerDotAI.github.io/fastasyncpg/core.html)
for table access (`db.t`), auto-generated dataclasses, queue helpers
(`claim_one`), and more.
