Module for working with PostgreSQL via asyncpg
Project description
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 # 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.3.0a2.tar.gz
(8.8 kB
view hashes)
Built Distribution
Close
Hashes for aioworkers_pg-0.3.0a2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 78e00e87f30543524b32060c5055356c1b0233377dddb9fcbad84003e85bdae3 |
|
MD5 | 15cce72b32b7b055c96af0f485f4b533 |
|
BLAKE2b-256 | 9d7c5aa5bb81c503fb72eca070a0345ec2ab2ff013322c428f4a80d759473344 |