Skip to main content

Parse PostgreSQL privileges

Project description

PyPI Version Documentation Travis Coverage Python Version PostgreSQL Version License

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

Installation

$ pip install pg_grant[sqlalchemy]

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

Example

>>> 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_acl
>>> engine = create_engine('postgresql://...')
>>> get_table_acl(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

Documentation

For in-depth information, visit the documentation!

Development

pg_grant uses semantic versioning

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

pg_grant-0.3.0.tar.gz (26.0 kB view details)

Uploaded Source

Built Distribution

pg_grant-0.3.0-py2.py3-none-any.whl (21.5 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file pg_grant-0.3.0.tar.gz.

File metadata

  • Download URL: pg_grant-0.3.0.tar.gz
  • Upload date:
  • Size: 26.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for pg_grant-0.3.0.tar.gz
Algorithm Hash digest
SHA256 dacf2791137b9a95f564a78e185ca31245bbb87572ae80a4f255504f901cda1a
MD5 dd081b95df1421e1bae828ecf99630c8
BLAKE2b-256 5e197906631e66947d3a0c3d10a43512d34a777e7d3c7dba1c453a659cd4c4ac

See more details on using hashes here.

Provenance

File details

Details for the file pg_grant-0.3.0-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for pg_grant-0.3.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 18e41aafc3296277f613419f1779e57f3fdf4377f4b4320ba28f868e02c6b11f
MD5 89eaccc9195566332561ff7ff206a8a8
BLAKE2b-256 0c6ac24968670466b8ff700a9725d0dc54f07572f139fd5730997c650885e598

See more details on using hashes here.

Provenance

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