Types#

class pg_grant.types.PgObjectType(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]#

Bases: Enum

PostgreSQL object type.

class pg_grant.types.Privileges(grantee: str, grantor: str, privs: List[str] = _Nothing.NOTHING, privswgo: List[str] = _Nothing.NOTHING)[source]#

Bases: object

Stores information from a parsed privilege string.

See also

parse_acl_item()

as_grant_statements(type: Literal[PgObjectType.TABLE, PgObjectType.SEQUENCE, PgObjectType.LANGUAGE, PgObjectType.SCHEMA, PgObjectType.DATABASE, PgObjectType.TABLESPACE, PgObjectType.TYPE, PgObjectType.FOREIGN_DATA_WRAPPER, PgObjectType.FOREIGN_SERVER, PgObjectType.FOREIGN_TABLE, PgObjectType.LARGE_OBJECT], target: str, *, schema: str | None = None, arg_types: List[str] | Tuple[str, ...] | None = None, quote_subname: bool = True) List[Executable][source]#
as_grant_statements(type: Literal[PgObjectType.TABLE], target: TableClause | Type[Any] | Mapper[Any], *, schema: None = None, arg_types: None = None, quote_subname: bool = True) List[Executable]
as_grant_statements(type: Literal[PgObjectType.SEQUENCE], target: Sequence, *, schema: None = None, arg_types: None = None, quote_subname: bool = True) List[Executable]
as_grant_statements(type: Literal[PgObjectType.FUNCTION], target: str, *, schema: str | None = None, arg_types: List[str] | Tuple[str, ...], quote_subname: bool = True) List[Executable]

Return array of grant() statements that can be executed to grant these privileges. Refer to the function documentation for the meaning of target and additional keyword arguments.

Note

This requires installing with the sqlalchemy extra.

as_revoke_statements(type: Literal[PgObjectType.TABLE, PgObjectType.SEQUENCE, PgObjectType.LANGUAGE, PgObjectType.SCHEMA, PgObjectType.DATABASE, PgObjectType.TABLESPACE, PgObjectType.TYPE, PgObjectType.FOREIGN_DATA_WRAPPER, PgObjectType.FOREIGN_SERVER, PgObjectType.FOREIGN_TABLE, PgObjectType.LARGE_OBJECT], target: str, *, schema: str | None = None, arg_types: List[str] | Tuple[str, ...] | None = None, quote_subname: bool = True) List[Executable][source]#
as_revoke_statements(type: Literal[PgObjectType.TABLE], target: TableClause | Type[Any] | Mapper[Any], *, schema: None = None, arg_types: None = None, quote_subname: bool = True) List[Executable]
as_revoke_statements(type: Literal[PgObjectType.SEQUENCE], target: Sequence, *, schema: None = None, arg_types: None = None, quote_subname: bool = True) List[Executable]
as_revoke_statements(type: Literal[PgObjectType.FUNCTION], target: str, *, schema: str | None = None, arg_types: List[str] | Tuple[str, ...], quote_subname: bool = True) List[Executable]

Return array of revoke() statements that can be executed to revoke these privileges. Refer to the function documentation for the meaning of target and additional keyword arguments.

Note

The statement for the privswgo privileges will revoke them fully, not only their grant options.

Note

This requires installing with the sqlalchemy extra.

class pg_grant.types.RelationInfo(*, oid: int, name: str, owner: str, acl)[source]#

Bases: object

Holds object information and privileges as queried using the query submodule.

oid: int#

Row identifier.

name: str#

Name of the table, sequence, etc.

owner: str#

Owner of the relation.

acl: Tuple[str, ...] | None#

Access control list.

class pg_grant.types.SchemaRelationInfo(*, oid: int, name: str, owner: str, acl, schema: str)[source]#

Bases: RelationInfo

Holds object information and privileges as queried using the query submodule.

schema: str#

The name of the schema that contains this relation.

class pg_grant.types.FunctionInfo(*, oid: int, name: str, owner: str, acl, schema: str, arg_types)[source]#

Bases: SchemaRelationInfo

Holds object information and privileges as queried using the query submodule.

arg_types: Tuple[str, ...]#

Data types of the function arguments.

class pg_grant.types.ColumnInfo(*, table_oid: int, schema: str, table: str, column: str, owner: str, acl)[source]#

Bases: object

Holds object information and privileges as queried using the query submodule.

table_oid: int#

Table identifier.

schema: str#

The name of the schema that contains the table.

table: str#

Name of the table.

column: str#

Name of the column.

owner: str#

Owner of the table.

acl: Tuple[str, ...] | None#

Column access control list.

class pg_grant.types.ParameterInfo(*, oid: int, name: str, acl)[source]#

Bases: object

Holds object information and privileges as queried using the query submodule.

oid: int#

Row identifier.

name: str#

Name of the table, sequence, etc.

acl: Tuple[str, ...] | None#

Access control list.