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

Uploaded Source

Built Distribution

pg_grant-0.3.3-py2.py3-none-any.whl (20.5 kB view details)

Uploaded Python 2 Python 3

File details

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

File metadata

  • Download URL: pg_grant-0.3.3.tar.gz
  • Upload date:
  • Size: 28.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.7

File hashes

Hashes for pg_grant-0.3.3.tar.gz
Algorithm Hash digest
SHA256 6207953eb42cffeb1b2b907b62fc59cff884beb0c3847c61415a1fc513c56fbe
MD5 fb22da002e2b68e0bda7982db7210e33
BLAKE2b-256 fa858c2beaba67a4444a867a71fd94b5454620af2a1c3c3901807ce863d9b60f

See more details on using hashes here.

Provenance

File details

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

File metadata

  • Download URL: pg_grant-0.3.3-py2.py3-none-any.whl
  • Upload date:
  • Size: 20.5 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.7

File hashes

Hashes for pg_grant-0.3.3-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 ceecee3da6e8282cf07b3088cc8e32927017545d8ce1cb53f328b7b70d5ec0c9
MD5 2ee61c27e739354be7724cbcfcfc533c
BLAKE2b-256 4613ed3be7b0692b36c63f417c08dbec4c17904f5f279bf58c74f22ac19d33c1

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