Metadata-Version: 2.1
Name: aioworkers-pg
Version: 0.2.1a0
Summary: Module for working with PostgreSQL via asyncpg
Home-page: https://github.com/aioworkers/aioworkers-pg
License: Apache Software License 2.0
Author: Alexander Bogushov
Author-email: abogushov@gmail.com
Requires-Python: >=3.6,<4.0
Classifier: Development Status :: 2 - Pre-Alpha
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: Apache Software License
Classifier: License :: Other/Proprietary License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.6
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Requires-Dist: aioworkers (>=0.15)
Requires-Dist: asyncpgsa
Project-URL: Repository, https://github.com/aioworkers/aioworkers-pg
Description-Content-Type: text/x-rst

aioworkers-pg
================

.. image:: https://travis-ci.org/aioworkers/aioworkers-pg.svg?branch=master
  :target: https://travis-ci.org/aioworkers/aioworkers-pg

.. image:: https://img.shields.io/pypi/pyversions/aioworkers-pg.svg
  :target: https://pypi.python.org/pypi/aioworkers-pg
  :alt: Python versions

.. image:: https://img.shields.io/pypi/v/aioworkers-pg.svg
  :target: https://pypi.python.org/pypi/aioworkers-pg


Asyncpg plugin for `aioworkers`.


Usage
-----

Add this to aioworkers config.yaml:

.. code-block:: yaml

    db:
        cls: aioworkers_pg.base.Connector
        dsn: postgresql:///test

You can get access to postgres anywhere via context:

.. code-block:: python

    await context.db.execute('CREATE TABLE users(id serial PRIMARY KEY, name text)')
    await context.db.execute(users.insert().values(name='Bob'))


Storage
~~~~~~~

.. code-block:: yaml

    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:


.. code-block:: shell

    pipenv install --dev --skip-lock


Run tests:

.. code-block:: shell

    pytest
