snowflake.core.user.UserCollection

class snowflake.core.user.UserCollection(root: Root)

Bases: AccountObjectCollectionParent[UserResource]

Represents the collection operations on the Snowflake User resource.

With this collection, you can create, iterate through, and search for users that you have access to in the current context.

Examples

Creating a user instance:

>>> sample_user = User(name="test_user")
>>> root.users.create(sample_user)
Copy

Attributes

root

Methods

create(user: UserModel, *, mode: CreateMode = CreateMode.error_if_exists) UserResource

Create a user in Snowflake account.

Parameters:
  • user (User) – The User object, together with the User’s properties: name; password, login_name, display_name, first_name, middle_name, last_name, email, must_change_password, disabled, days_to_expiry, mins_to_unlock, default_warehouse, default_namespace, default_role, default_secondary_roles, mins_to_bypass_mfa, rsa_public_key, rsa_public_key_fp, rsa_public_key_2, rsa_public_key_2_fp, comment, type, enable_unredacted_query_syntax_error, network_policy are optional

  • mode (CreateMode, optional) –

    One of the following enum values.

    CreateMode.error_if_exists: Throw an snowflake.core.exceptions.ConflictError if the user already exists in Snowflake. Equivalent to SQL create user <name> ....

    CreateMode.or_replace: Replace if the user already exists in Snowflake. Equivalent to SQL create or replace user <name> ....

    CreateMode.if_not_exists: Do nothing if the user already exists in Snowflake. Equivalent to SQL create user <name> if not exists...

    Default is CreateMode.error_if_exists.

Examples

Creating a user, replacing any existing user with the same name:

>>> sample_user = User(name = "test_user")
>>> root.users.create(sample_user, mode = CreateMode.or_replace)
Copy
items() ItemsView[str, T]
iter(like: str | None = None, limit: int | None = None, starts_with: str | None = None, from_name: str | None = None) Iterator[UserModel]
keys() KeysView[str]
values() ValuesView[T]
Language: English