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_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)
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.3.2.tar.gz
(28.9 kB
view details)
Built Distribution
File details
Details for the file pg_grant-0.3.2.tar.gz
.
File metadata
- Download URL: pg_grant-0.3.2.tar.gz
- Upload date:
- Size: 28.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.4.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.8.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e407693541e58b42fb23aee948fb3c665704b061fde7259f43cf0087cdf2ed0b |
|
MD5 | 5d8a19b2da1c3037811515bca7aafb59 |
|
BLAKE2b-256 | 714325be147dc96082f8b4708234c68a767c81d88f4082e377448aab80629015 |
Provenance
File details
Details for the file pg_grant-0.3.2-py2.py3-none-any.whl
.
File metadata
- Download URL: pg_grant-0.3.2-py2.py3-none-any.whl
- Upload date:
- Size: 20.4 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.4.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.8.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 941c4195c6c9cc7489fac5eab41c805a4d066aa64fc2cfd7fd4eac1685a17a42 |
|
MD5 | 32803f3668758d5bcb6c1bbbdccc598c |
|
BLAKE2b-256 | 4426098d3ade7cf474d4953edebc105efa5ead1fc882bbf5845a5e367f2499af |