Skip to main content

Module for working with PostgreSQL via asyncpg

Project description

aioworkers-pg

GitHub Workflow Status PyPI - Python Version PyPI

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


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.0.tar.gz (8.8 kB view details)

Uploaded Source

Built Distribution

aioworkers_pg-0.3.0-py3-none-any.whl (9.8 kB view details)

Uploaded Python 3

File details

Details for the file aioworkers-pg-0.3.0.tar.gz.

File metadata

  • Download URL: aioworkers-pg-0.3.0.tar.gz
  • Upload date:
  • Size: 8.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.13 CPython/3.8.12 Linux/5.4.0-1069-azure

File hashes

Hashes for aioworkers-pg-0.3.0.tar.gz
Algorithm Hash digest
SHA256 b58624743fb271049a065debeeadc4c5aee27a3bcd0d6f05a3b82232cd86842f
MD5 da548fecb59570deabbe2a741eca364a
BLAKE2b-256 ebf43efc5e6c97dab12542b08dd7cabb1a78b4a474c2957bcc32108876cc1990

See more details on using hashes here.

File details

Details for the file aioworkers_pg-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: aioworkers_pg-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 9.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.13 CPython/3.8.12 Linux/5.4.0-1069-azure

File hashes

Hashes for aioworkers_pg-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7c5b46b3573062ff3c4b9b20b9ab7768cb84e5549c10d42a72f96e2dc8013848
MD5 b744c51d3ea39831de36302f4c4bfa25
BLAKE2b-256 6584ba25f144e8ccaa63f3fe8b2ab71a1a3ab185bdb15a5e798fbc4a8d48f37c

See more details on using hashes here.

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