Metadata-Version: 2.0
Name: pg-grant
Version: 0.2.0
Summary: Parse PostgreSQL privileges
Home-page: https://github.com/RazerM/pg_grant
Author: Frazer McLean
Author-email: frazer@frazermclean.co.uk
License: MIT
Platform: UNKNOWN
Classifier: Development Status :: 4 - Beta
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Requires-Dist: attrs
Requires-Dist: typing; python_version<"3.5"
Provides-Extra: docstest
Requires-Dist: sphinx-rtd-theme; extra == 'docstest'
Requires-Dist: doc8; extra == 'docstest'
Requires-Dist: sphinx; extra == 'docstest'
Provides-Extra: pep8test
Requires-Dist: flake8; extra == 'pep8test'
Requires-Dist: pep8-naming; extra == 'pep8test'
Provides-Extra: sqlalchemy
Requires-Dist: sqlalchemy[postgresql]; extra == 'sqlalchemy'
Provides-Extra: test
Requires-Dist: plumbum; extra == 'test'
Requires-Dist: testcontainers; extra == 'test'
Requires-Dist: testing.postgresql; extra == 'test'
Requires-Dist: pytest (>=3.0); extra == 'test'

pg_grant
-------------

|PyPI Version| |Documentation| |Travis| |Coverage| |Python Version| |MIT License|

``pg_grant`` is a Python module for parsing, querying, and updating PostgreSQL
privileges.

Installation
~~~~~~~~~~~~

.. code:: bash

    $ pip install pg_grant[sqlalchemy]

Without the SQLAlchemy extra, ``pg_grant`` can only parse access privileges.

Example
~~~~~~~

.. code:: python

   >>> from pg_grant import parse_acl_item
   >>> parse_acl_item('bob=arw*/alice')
   Privileges(grantee='bob', grantor='alice', privs=['SELECT', 'INSERT'], privswgo=['UPDATE'])

   >>> from sqlalchemy import create_engine
   >>> from pg_grant.query import get_table_acls
   >>> engine = create_engine('postgresql://...')
   >>> get_table_acls(engine, 'table2')
   SchemaRelationInfo(oid=138067, name='table2', owner='alice', acl=['alice=arwdDxt/alice', 'bob=arwdDxt/alice'], schema='public')

   >>> from pg_grant import PgObjectType
   >>> from pg_grant.sql import revoke
   >>> stmt = revoke(['SELECT'], PgObjectType.TABLE, 'table2', 'bob')
   >>> str(stmt)
   'REVOKE SELECT ON TABLE table2 FROM bob'
   >>> engine.execute(stmt)

Authors
~~~~~~~
- Frazer McLean <frazer@frazermclean.co.uk>

Documentation
~~~~~~~~~~~~~

For in-depth information, `visit the
documentation <http://pg_grant.readthedocs.org/en/latest/>`__!

Development
~~~~~~~~~~~

pg_grant uses `semantic versioning <http://semver.org>`__

.. |Travis| image:: http://img.shields.io/travis/RazerM/pg_grant/master.svg?style=flat-square&label=travis
   :target: https://travis-ci.org/RazerM/pg_grant
.. |PyPI Version| image:: http://img.shields.io/pypi/v/pg_grant.svg?style=flat-square
   :target: https://pypi.python.org/pypi/pg_grant/
.. |Python Version| image:: https://img.shields.io/badge/python-3-brightgreen.svg?style=flat-square
   :target: https://www.python.org/downloads/
.. |MIT License| image:: http://img.shields.io/badge/license-MIT-blue.svg?style=flat-square
   :target: https://raw.githubusercontent.com/RazerM/pg_grant/master/LICENSE.txt
.. |Coverage| image:: https://img.shields.io/codecov/c/github/RazerM/pg_grant/master.svg?style=flat-square
   :target: https://codecov.io/github/RazerM/pg_grant?branch=master
.. |Documentation| image:: https://img.shields.io/badge/docs-latest-brightgreen.svg?style=flat-square
   :target: http://pg_grant.readthedocs.org/en/latest/


