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.1a5.tar.gz
(7.8 kB
view hashes)
Built Distribution
Close
Hashes for aioworkers_pg-0.2.1a5-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | bbb56070608f7e582e64cdc4559d948a368160f503d301d8c2601e964303a96d |
|
MD5 | 9ec787078362bbf4d02bfd47a05bd0c1 |
|
BLAKE2b-256 | c6dac61298c7969f1fbe4fbf786fe8349707adb7a2e8c3a40204981ff61a2d2f |