snowflake.core.database_role.DatabaseRoleCollection¶
- class snowflake.core.database_role.DatabaseRoleCollection(database: DatabaseResource, root: Root)¶
- Bases: - DatabaseObjectCollectionParent[- DatabaseRoleResource]- Represents the collection operations on the Snowflake DatabaseRole resource. - With this collection, you can create, iterate through, and search for database roles that you have access to in the current context. - Examples - Creating a database role instance: - >>> database_role_collection = root.databases["my_db"].database_roles >>> database_role_collection.create(DatabaseRole(name="test-role", comment="samplecomment")) - Attributes - database¶
- The DatabaseResource this collection belongs to. 
 - root¶
- The Root object this collection belongs to. 
 - Methods - create(database_role: DatabaseRole, *, mode: CreateMode = CreateMode.error_if_exists) DatabaseRoleResource¶
- Create a database role in Snowflake. - Parameters:
- database_role (DatabaseRole) – The - DatabaseRoleobject, together with the- DatabaseRole’s properties: name; comment is optional
- mode (CreateMode, optional) – - One of the following enum values. - CreateMode.error_if_exists: Throw an- snowflake.core.exceptions.ConflictErrorif the database role already exists in Snowflake. Equivalent to SQL- create database role <name> ....- CreateMode.or_replace: Replace if the database role already exists in Snowflake. Equivalent to SQL- create or replace database role <name> ....- CreateMode.if_not_exists: Do nothing if the database role already exists in Snowflake. Equivalent to SQL- create database role <name> if not exists...- Default is - CreateMode.error_if_exists.
 
 - Examples - Creating a database role, replacing any existing database role with the same name: - >>> database_role = DatabaseRole(name="test-role", comment="samplecomment") >>> database_role_ref = root.databases["my_db"].database_roles.create( ... database_role, mode=CreateMode.or_replace ... ) 
 - create_async(database_role: DatabaseRole, *, mode: CreateMode = CreateMode.error_if_exists) PollingOperation[DatabaseRoleResource]¶
- An asynchronous version of - create().- Refer to - PollingOperationfor more information on asynchronous execution and the return type.
 - items() ItemsView[str, T]¶
 - iter(*, limit: int | None = None, from_name: str | None = None) Iterator[DatabaseRole]¶
- Iterate through - DatabaseRoleobjects from Snowflake, filtering on any optional ‘from_name’ pattern.- Parameters:
- show_limit (int, optional) – Limit of the maximum number of rows returned by iter(). The default is - None, which behaves equivalently to show_limit=10000. This value must be between- 1and- 10000.
- from_name (str, optional) – Fetch rows only following the first row whose object name matches the specified string. This is case-sensitive and does not have to be the full name. 
 
 - Examples - Showing all database roles that you have access to see: - >>> database_roles = database_role_collection.iter() - Showing roles from ‘your-role-name-‘: - >>> database_roles = database_role_collection.iter(from_name="your-role-name-") - Using a for loop to retrieve information from iterator: - >>> for database_role in database_roles: ... print(database_role.name, database_role.comment) 
 - iter_async(*, limit: int | None = None, from_name: str | None = None) PollingOperation[Iterator[DatabaseRole]]¶
- An asynchronous version of - iter().- Refer to - PollingOperationfor more information on asynchronous execution and the return type.
 - keys() KeysView[str]¶
 - update_reference(old_name: str, new_name: str, resource: T) None¶
- Update the collection with a new item. 
 - values() ValuesView[T]¶