snowflake.core.account.AccountCollection

class snowflake.core.account.AccountCollection(root: Root)

Bases: AccountObjectCollectionParent[AccountResource]

Represents the collection operations of the Snowflake Account resource.

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

Examples

Creating an account instance:

>>> account_collection = root.accounts
>>> account = Account(
...     name="MY_ACCOUNT",
...     admin_name = "admin"
...     admin_password = 'TestPassword1'
...     first_name = "Jane"
...     last_name = "Smith"
...     email = 'myemail@myorg.org'
...     edition = "enterprise"
...     region = "aws_us_west_2"
...  )
>>> account_collection.create(account)
Copy

Attributes

root

Methods

create(account: AccountModel) AccountResource

Create an account in Snowflake.

Parameters:

account (Account) – The Account object, together with the Account’s properties: name, admin_name, email, edition; admin_password, first_name, last_name, must_change_password, region_group, region, comment, polaris are optional.

Examples

Creating an account instance and getting reference to it:

>>> account = Account(
...     name="MY_ACCOUNT",
...     admin_name = "admin"
...     admin_password = 'TestPassword1'
...     first_name = "Jane"
...     last_name = "Smith"
...     email = 'myemail@myorg.org'
...     edition = "enterprise"
...     region = "aws_us_west_2"
...  )
>>> # Use the account collection created before to create a referece to the account resource
>>> # in Snowflake.
>>> account_reference = account_collection.create(account)
Copy
items() ItemsView[str, T]
iter(*, like: str | None = None, limit: int | None = None, history: bool | None = None) Iterator[AccountModel]

Iterate through Account objects in Snowflake, filtering on any optional like pattern.

Parameters:
  • like (str, optional) – A case-insensitive string functioning as a filter, with support for SQL wildcard characters (% and _).

  • 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 1 and 10000.

  • history (bool, optional) – If True, includes dropped accounts that have not yet been deleted. The default is None, which behaves equivalently to False.

Examples

Showing all accounts you have access to see:

>>> accounts = account_collection.iter()
Copy

Showing information of the exact account you want to see:

>>> accounts = account_collection.iter(like="your-account-name")
Copy

Showing accounts starting with ‘your-account-name’:

>>> accounts = account_collection.iter(like="your-account-name%")
Copy

Using a for loop to retrieve information from iterator:

>>> for account in accounts:
>>>     print(account.name, account.comment)
Copy
keys() KeysView[str]
values() ValuesView[T]
Language: English