aioworkers-pg
Asyncpg plugin for aioworkers
.
Usage
Connection
Add this to aioworkers config.yaml:
db:
cls: aioworkers_pg.base.Connector
dsn: postgresql:///test
You can get access to postgres anywhere via context:
await context.db.execute('CREATE TABLE users(id serial PRIMARY KEY, name text)')
await context.db.execute(users.insert().values(name='Bob'))
Connection additional
db:
cls: aioworkers_pg.base.Connector
dsn: postgresql:///test
pool:
min_size: 1
max_size: 100
Storage
storage:
cls: aioworkers_pg.storage.RoStorage
dsn: postgresql:///test
table: mytable
key: id
get: SELECT * FROM mytable WHERE id = :id
format: dict
Development
Install dev requirements:
poetry install
Run postgres:
docker run --rm -p 5432:5432 --name postgres -e POSTGRES_PASSWORD=postgres -e POSTGRES_DB=test -d postgres
Run tests:
pytest