Skip to main content

Module for working with PostgreSQL via asyncpg

Project description Coverage Code style: ruff Code style: black Code style: Mypy Documentation Status Python versions Hatch project

Asyncpg plugin for aioworkers.



Add this to aioworkers config.yaml:

  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

  cls: aioworkers_pg.base.Connector
  dsn: postgresql:///test
    min_size: 1
    max_size: 100
  connection:  # optional
    init: mymodule.connection_init
    setup: mymodule.connection_setup
    class: mymodule.Connection


  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


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

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)

Uploaded Source

Built Distribution

aioworkers_pg-0.4.0a1-py3-none-any.whl (11.3 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page