Module for working with PostgreSQL via asyncpg
Project description
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
connection: # optional
init: mymodule.connection_init
setup: mymodule.connection_setup
class: mymodule.Connection
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
Check code:
hatch run lint:all
Format code:
hatch run lint:fmt
Run postgres:
docker run --rm -p 5432:5432 --name postgres -e POSTGRES_PASSWORD=postgres -e POSTGRES_DB=test -d postgres
Run tests:
hatch run pytest
Run tests with coverage:
hatch run cov
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.4.0a1.tar.gz
(10.2 kB
view hashes)
Built Distribution
Close
Hashes for aioworkers_pg-0.4.0a1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 02e1eddbcc1400fc4cdea293bbc647554c66dcbeb04a9cf215c92b1079058c06 |
|
MD5 | 2c42061eaf3213c51dd0f8d4485e9d69 |
|
BLAKE2b-256 | 42b23ef85e6f6bc7941cfd2484f08462606cdbff1d8d90e456961c29b43d74f9 |