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.1a6.tar.gz
(7.9 kB
view hashes)
Built Distribution
Close
Hashes for aioworkers_pg-0.2.1a6-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ae27e9e6cbcbef7d7cfbc52bff16f38c53a3d4c6f6361881549e4d1eb3d11122 |
|
MD5 | 9a7b966ffb1ae71a6ce971d227d7cd56 |
|
BLAKE2b-256 | 7d03d86eec54d673cab6698e88865a54a53eb1bb9315d019eb410dfd3876bcdc |