SQL Constructs#
- pg_grant.sql.grant(privileges: List[str] | Tuple[str] | Literal['ALL'], type: Literal[PgObjectType.TABLE, PgObjectType.SEQUENCE, PgObjectType.LANGUAGE, PgObjectType.SCHEMA, PgObjectType.DATABASE, PgObjectType.TABLESPACE, PgObjectType.TYPE, PgObjectType.DOMAIN, PgObjectType.FOREIGN_DATA_WRAPPER, PgObjectType.FOREIGN_SERVER, PgObjectType.FOREIGN_TABLE, PgObjectType.LARGE_OBJECT, PgObjectType.PARAMETER], target: str, grantee: str, *, grant_option: bool = False, schema: str | None = None, arg_types: List[str] | Tuple[str, ...] | None = None, quote_subname: bool = True) Executable [source]#
- pg_grant.sql.grant(privileges: List[str] | Tuple[str] | Literal['ALL'], type: Literal[PgObjectType.TABLE], target: TableClause | Type[Any] | Mapper[Any], grantee: str, *, grant_option: bool = False, schema: None = None, arg_types: None = None, quote_subname: bool = True) Executable
- pg_grant.sql.grant(privileges: List[str] | Tuple[str] | Literal['ALL'], type: Literal[PgObjectType.SEQUENCE], target: Sequence, grantee: str, *, grant_option: bool = False, schema: None = None, arg_types: None = None, quote_subname: bool = True) Executable
- pg_grant.sql.grant(privileges: List[str] | Tuple[str] | Literal['ALL'], type: Literal[PgObjectType.FUNCTION], target: str, grantee: str, *, grant_option: bool = False, schema: str | None = None, arg_types: List[str] | Tuple[str, ...], quote_subname: bool = True) Executable
GRANT statement that may be executed by SQLAlchemy.
- Parameters:
privileges – List of privileges (or
'ALL'
).type – PostgreSQL object type.
target – Object name, or appropriate SQLAlchemy object (e.g.
Table
or a declarative class).grantee – Role to receive privileges.
grant_option – Whether the recipient may in turn grant these privileges to others.
schema – Optional schema, if target is a string.
arg_types – Sequence of argument types for granting privileges on functions. E.g.
('int4', 'int4')
or()
.quote_subname – Quote subname identifier in privileges, e.g.
'SELECT (user)'
->'SELECT ("user")
. This should only beFalse
if the subname is already a valid identifier.
- pg_grant.sql.revoke(privileges: List[str] | Tuple[str] | Literal['ALL'], type: Literal[PgObjectType.TABLE, PgObjectType.SEQUENCE, PgObjectType.LANGUAGE, PgObjectType.SCHEMA, PgObjectType.DATABASE, PgObjectType.TABLESPACE, PgObjectType.TYPE, PgObjectType.DOMAIN, PgObjectType.FOREIGN_DATA_WRAPPER, PgObjectType.FOREIGN_SERVER, PgObjectType.FOREIGN_TABLE, PgObjectType.LARGE_OBJECT, PgObjectType.PARAMETER], target: str, grantee: str, *, grant_option: bool = False, schema: str | None = None, arg_types: List[str] | Tuple[str, ...] | None = None, quote_subname: bool = True) Executable [source]#
- pg_grant.sql.revoke(privileges: List[str] | Tuple[str] | Literal['ALL'], type: Literal[PgObjectType.TABLE], target: TableClause | Type[Any] | Mapper[Any], grantee: str, *, grant_option: bool = False, schema: None = None, arg_types: None = None, quote_subname: bool = True) Executable
- pg_grant.sql.revoke(privileges: List[str] | Tuple[str] | Literal['ALL'], type: Literal[PgObjectType.SEQUENCE], target: Sequence, grantee: str, *, grant_option: bool = False, schema: None = None, arg_types: None = None, quote_subname: bool = True) Executable
- pg_grant.sql.revoke(privileges: List[str] | Tuple[str] | Literal['ALL'], type: Literal[PgObjectType.FUNCTION], target: str, grantee: str, *, grant_option: bool = False, schema: str | None = None, arg_types: List[str] | Tuple[str, ...], quote_subname: bool = True) Executable
REVOKE statement that may be executed by SQLAlchemy.
- Parameters:
privileges – List of privileges (or
'ALL'
).type – PostgreSQL object type.
target – Object name, or appropriate SQLAlchemy object (e.g.
Table
or a declarative class).grantee – Role to lose privileges.
grant_option – Whether to revoke the grant option for these privileges.
schema – Optional schema, if target is a string.
arg_types – Sequence of argument types for revoking privileges on functions. E.g.
('int4', 'int4')
or()
.quote_subname – Quote subname identifier in privileges, e.g.
'SELECT (user)'
->'SELECT ("user")
. This should only beFalse
if the subname is already a valid identifier.
Warning
When
grant_option=True
, only the grant option is revoked, not the privilege(s).