Module for working with PostgreSQL via asyncpg
Project description
aioworkers-pg
Asyncpg plugin for aioworkers
.
Usage
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'))
Storage
storage:
cls: aioworkers_pg.storage.RoStorage
dsn: postgresql:///test
table: mytable # optional instead custom sql
key: id
get: SELECT * FROM mytable WHERE id = :id # optional custom sql
format: dict # or row
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
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
aioworkers-pg-0.2.2.tar.gz
(8.2 kB
view hashes)
Built Distribution
Close
Hashes for aioworkers_pg-0.2.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 346d22d9b18400f198c4f3a64abe21ef500c94745f86cf26032d15d7bc220523 |
|
MD5 | e1b70a006cb0a6558a0f6f3ed4033f10 |
|
BLAKE2b-256 | 6394807ed3cafe0b391a4a808f644b8fe1eb4039f41c7701b391a633f9b152c4 |