Parse PostgreSQL privileges
Project description
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_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)
Documentation
For in-depth information, visit the documentation!
Development
pg_grant uses semantic versioning
Project details
Release history Release notifications | RSS feed
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.2.0.post0.tar.gz
(22.0 kB
view details)
Built Distribution
File details
Details for the file pg_grant-0.2.0.post0.tar.gz
.
File metadata
- Download URL: pg_grant-0.2.0.post0.tar.gz
- Upload date:
- Size: 22.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 71ceb34c681bf4bcb95b523126aa4a8742292089e599dc758af64cac85933a7b |
|
MD5 | ca9424b408b0879e0a3433ed2031e84a |
|
BLAKE2b-256 | cac6509afd3b3fa75963ea0f0adffda55318d9d8782a554388c0c9cead467d7b |
Provenance
File details
Details for the file pg_grant-0.2.0.post0-py2.py3-none-any.whl
.
File metadata
- Download URL: pg_grant-0.2.0.post0-py2.py3-none-any.whl
- Upload date:
- Size: 18.4 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | bbd4ef98e3fd416b14595e7a2764480ac58fa89966d0345b4768b8d8a59141cc |
|
MD5 | 3f5cfa875a5379d37fdcc493037819ba |
|
BLAKE2b-256 | 0b9bf24c15c35ec80603a6446f40cf2f1ecde99b9ea53cc2ba9e6d771741fbf5 |