snowflake.core.schema.SchemaResource

class snowflake.core.schema.SchemaResource(name: str, collection: SchemaCollection)

Bases: DatabaseObjectReferenceMixin[SchemaCollection]

Represents a reference to a Snowflake schema.

With this schema reference, you can fetch information about a schema, as well as perform certain actions on it.

Attributes

alerts

The AlertCollection of all alerts contained in this schema.

Examples

Getting all alerts in my_schema:

>>> my_db.schemas["my_schema"].alerts
artifact_repositories

The ArtifactRepositoryCollection of all artifact repositories in this schema.

Examples

Getting all artifact repositories in my_schema:

>>> my_db.schemas["my_schema"].artifact_repositories
cortex_search_services

The CortexSearchServiceCollection of all cortex services contained in this schema.

Examples

Getting all cortex search services in my_schema:

>>> my_db.schemas["my_schema"].cortex_search_service
database

The DatabaseResource this reference belongs to.

dynamic_tables

The DynamicTableCollection of all dynamic tables contained in this schema.

Examples

Getting all dynamic tables in my_schema:

>>> my_db.schemas["my_schema"].dynamic_tables
event_tables

The EventCollection of all events contained in this schema.

Examples

Getting all events in my_schema:

>>> my_db.schemas["my_schema"].events
functions

The FunctionCollection of all functions contained in this schema.

Examples

Getting all functions in my_schema:

>>> my_db.schemas["my_schema"].functions
iceberg_tables

The IcebergTableCollection of all dynamic tables contained in this schema.

Examples

Getting all Iceberg tables in my_schema:

>>> my_db.schemas["my_schema"].iceberg_tables
image_repositories

The ImageRepositoryCollection of all image repositories in this schema.

Examples

Getting all image repositories in my_schema:

>>> my_db.schemas["my_schema"].image_repositories
network_rules

The NetworkRuleCollection of all network rules contained in this schema.

Examples

Get all network rules in my_schema:

>>> my_db.schemas["my_schema"].network_rules
notebooks

The NotebookCollection of all notebooks contained in this schema.

Examples

Getting all notebooks in my_schema:

>>> my_db.schemas["my_schema"].notebooks
password_policies

The PasswordPolicyCollection of all password policies contained in this schema.

Examples

Get all password policies in my_schema:

>>> my_db.schemas["my_schema"].password_policies
pipes

The PipesCollection of all pipes in this schema.

Examples

Getting all pipes in my_schema:

>>> my_db.schemas["my_schema"].pipes
procedures

Returns the ProcedureCollection that represents the visible procedures.

Examples

Getting a specific procedure resource:

>>> root = Root(session)
>>> procedure = root.databases["my_db"].schemas["my_schema"].procedures["my_procedure"]
qualified_name

Return the qualified name of the object this reference points to.

root

The Root object this reference belongs to.

secrets

The SecretCollection of all secrets contained in this schema.

Examples

Get all secrets in my_schema:

>>> my_db.schemas["my_schema"].secrets
sequences

The SequenceCollection of all sequences contained in this schema.

Examples

Get all sequences in my_schema:

>>> my_db.schemas["my_schema"].sequences
services

The ServiceCollection of all services contained in this schema.

Examples

Getting all services in my_schema:

>>> my_db.schemas["my_schema"].services
stages

The StageCollection of all stages contained in this schema.

Examples

Getting all stages in my_schema:

>>> my_db.schemas["my_schema"].stages
streamlits

The StreamlitCollection of all Streamlits contained in this schema.

Examples

Getting all streamlits in my_schema:

>>> my_db.schemas["my_schema"].streamlits
streams

The StreamCollection of all streams contained in this schema.

Examples

Getting all streams in my_schema:

>>> my_db.schemas["my_schema"].streams
tables

The TableCollection of all tables contained in this schema.

Examples

Getting all tables in my_schema:

>>> my_db.schemas["my_schema"].tables
tags

The TagCollection of all tags contained in this schema.

Examples

Get all tags in my_schema:

>>> my_db.schemas["my_schema"].tags
tasks

The TaskCollection of all tasks contained in this schema.

Examples

Getting all tasks in my_schema:

>>> my_db.schemas["my_schema"].tasks
user_defined_functions

The UserDefinedFunctionCollection of all user defined functions contained in this schema.

Examples

Get all user defined functions in my_schema:

>>> my_db.schemas["my_schema"].user_defined_functions
views

The ViewCollection of all views contained in this schema.

Examples

Getting all views in my_schema:

>>> my_db.schemas["my_schema"].views

Methods

create_or_alter(schema: SchemaModel) SchemaResource

Create, or alter-in-place a schema in Snowflake.

Parameters:

schema (SchemaResource) – An instance of Schema, the definition of schema we should create.

Examples

Create a schema from a reference:

>>> my_db.schemas["my_new_schema"].create_or_alter(Schema("my_new_schema"))
create_or_alter_async(schema: SchemaModel) PollingOperation[SchemaResource]

An asynchronous version of create_or_alter().

Refer to PollingOperation for more information on asynchronous execution and the return type.

create_or_update(schema: SchemaModel) SchemaResource

The create_or_update() method is deprecated; use create_or_alter() instead.

Create, or update-in-place a schema in Snowflake.

schema: SchemaResource

An instance of Schema, the definition of schema we should create.

Create a schema from a reference:

>>> my_db.schemas["my_new_schema"].create_or_update(Schema("my_new_schema"))
delete(if_exists: bool | None = None) None

The delete() method is deprecated; use drop() instead.

Delete this schema.

if_exists: bool, optional

Check the existence of this schema before dropping it. Default is None, which is equivalent to False.

Deleting a schema using its reference, erroring if it doesn’t exist:

>>> schema_reference.delete()

Deleting a schema using its reference, if it exists:

>>> schema_reference.delete(if_exists=True)
drop(if_exists: bool | None = None) None

Drop this schema.

Parameters:

if_exists (bool, optional) – Check the existence of this schema before dropping it. Default is None, which is equivalent to False.

Examples

Dropping a schema using its reference, erroring if it doesn’t exist:

>>> schema_reference.drop()

Dropping a schema using its reference, if it exists:

>>> schema_reference.drop(if_exists=True)
drop_async(if_exists: bool | None = None) PollingOperation[None]

An asynchronous version of drop().

Refer to PollingOperation for more information on asynchronous execution and the return type.

fetch() SchemaModel

Fetch the details of a schema.

Examples

Fetching a reference to a schema to print its name and whether it’s our current one.

>>> my_schema = my_db.schemas["my_schema"].fetch()
>>> print(my_schema.name, my_schema.is_current)
fetch_async() PollingOperation[SchemaModel]

An asynchronous version of fetch().

Refer to PollingOperation for more information on asynchronous execution and the return type.

get_tags(with_lineage: bool | None = None) dict[TagResource, TagValue]

Get the tag assignments for a schema.

Returns all tags assigned to a schema. This operation requires an active warehouse.

Parameters:

with_lineage (bool, optional) – Parameter that specifies whether tag assignments inherited by the object from its ancestors in securable object hierarchy should be returned as well: - true: All tags assigned to this object should be returned, inheritance included. - false: Only tags explicitly assigned to this object should be returned.

get_tags_async(with_lineage: bool | None = None) PollingOperation[dict[TagResource, TagValue]]

An asynchronous version of get_tags().

Refer to PollingOperation for more information on asynchronous execution and the return type.

set_tags(tags: dict[TagResource, TagValue], if_exists: bool | None = None) None

Set tags on a schema.

Parameters:
  • tags (dict[TagResource, TagValue]) – (required)

  • if_exists (bool) – Parameter that specifies how to handle the request for a resource that does not exist: - true: The endpoint does not throw an error if the resource does not exist. It returns a 200 success response, but does not take any action on the resource. - false: The endpoint throws an error if the resource doesn’t exist.

set_tags_async(tags: dict[TagResource, TagValue], if_exists: bool | None = None) PollingOperation[None]

An asynchronous version of set_tags().

Refer to PollingOperation for more information on asynchronous execution and the return type.

undrop() None

Undrop this previously dropped schema if it hasn’t been purged yet.

Examples

Undropping a schema using its reference:

>>> schema_reference.drop()
>>> schema_reference.undrop()
undrop_async() PollingOperation[None]

An asynchronous version of undrop().

Refer to PollingOperation for more information on asynchronous execution and the return type.

unset_tags(tag_resources: set[TagResource], if_exists: bool | None = None) None

Unset tags from a schema.

Parameters:
  • tag_resources (set[TagResource]) – (required)

  • if_exists (bool) – Parameter that specifies how to handle the request for a resource that does not exist: - true: The endpoint does not throw an error if the resource does not exist. It returns a 200 success response, but does not take any action on the resource. - false: The endpoint throws an error if the resource doesn’t exist.

unset_tags_async(tag_resources: set[TagResource], if_exists: bool | None = None) PollingOperation[None]

An asynchronous version of unset_tags().

Refer to PollingOperation for more information on asynchronous execution and the return type.