snowflake.core.Root¶
- class snowflake.core.Root(connection: SnowflakeConnection | Session)¶
Bases:
object
The entry point of the Snowflake Core Python APIs that manage the Snowflake objects.
- Parameters:
connection (Union[SnowflakeConnection, Session]) – A
SnowflakeConnection
or SnowparkSession
instance.
Examples
Creating a
Root
instance:>>> from snowflake.connector import connect >>> from snowflake.core import Root >>> from snowflake.snowpark import Session >>> CONNECTION_PARAMETERS = { ... "account": os.environ["snowflake_account_demo"], ... "user": os.environ["snowflake_user_demo"], ... "password": os.environ["snowflake_password_demo"], ... "database": test_database, ... "warehouse": test_warehouse, ... "schema": test_schema, ... } >>> # create from a Snowflake Connection >>> connection = connect(**CONNECTION_PARAMETERS) >>> root = Root(connection) >>> # or create from a Snowpark Session >>> session = Session.builder.config(CONNECTION_PARAMETERS).create() >>> root = Root(session)
Using the
Root
instance to access resource management APIs:>>> tasks = root.databases["mydb"].schemas["myschema"].tasks >>> mytask = tasks["mytask"] >>> mytask.resume() >>> compute_pools = root.compute_pools >>> my_computepool = compute_pools["mycomputepool"] >>> my_computepool.delete()
Attributes
- accounts¶
Returns the
AccountCollection
that represents the visible accounts.Examples
Getting a specific account resource:
>>> root = Root(session) >>> my_account = root.accounts["my_account"]
- catalog_integrations¶
Returns the
CatalogIntegrationCollection
that represents the visible catalog integrations.Examples
Getting a specific catalog integration resource:
>>> root = Root(session) >>> my_catalog_integration = root.catalog_integrations["my_catalog_integration"]
- compute_pools¶
Returns the
ComputePoolCollection
that represents the visible compute pools.Examples
Getting a specific compute pool resource:
>>> root = Root(session) >>> my_cp = root.compute_pools["my_cp"]
- connection¶
Return the connection in use.
This is the connection used to create this
Root
instance, or the Snowpark session’s connection if this root is created from a session.
- databases¶
Returns the
DatabaseCollection
that represents the visible databases.Examples
Getting a specific database resource:
>>> root = Root(session) >>> my_db = root.databases["my_db"]
- external_volumes¶
Returns the
ExternalVolumeCollection
that represents the visible external volumes.Examples
Getting a specific external volume resource:
>>> root = Root(session) >>> my_external_volume = root.external_volumes["my_external_volume"]
- grants¶
Returns the visible Grants in Snowflake.
Examples
Using the
Grants
object to grant a privilege to a role:>>> grants.grant( ... Grant( ... grantee=Grantees.role(name="public"), ... securable=Securables.database("invaliddb123"), ... privileges=[Privileges.create_database], ... grant_option=False, ... ) ... )
- managed_accounts¶
Returns the
ManagedAccountCollection
that represents the visible accounts.Examples
Getting a specific managed account resource:
>>> root = Root(session) >>> my_managed_account = root.managed_accounts["my_managed_account"]
- network_policies¶
Returns the
NetworkPolicyCollection
that represents the visible network policies.Examples
Getting a specific network policy resource:
>>> root = Root(session) >>> my_network_policy = root.network_policies["my_network_policy"]
- notification_integrations¶
Returns the
NotificationIntegrationCollection
that represents the visible notification integrations.Examples
Listing all available Notification Integrations:
>>> root = Root(session) >>> my_nis = list(root.notification_integrations.iter())
- roles¶
Returns the
RoleCollection
that represents the visible roles.Examples
Getting a specific role resource:
>>> root = Root(session) >>> my_role = root.roles["my_role"]
- session¶
Returns the session that is used to create this
Root
instance.
- users¶
Returns the
UserCollection
that represents the visible users.Examples
Getting a specific user resource:
>>> root = Root(session) >>> my_user = root.users["my_user"]
- warehouses¶
Returns the
WarehouseCollection
that represents the visible warehouses.Examples
Getting a specific warehouse resource:
>>> root = Root(session) >>> my_wh = root.warehouses["my_wh"]
Methods
- parameters(refresh: bool = False) SnowApiParameters ¶