snowflake.core.schema.SchemaResourceΒΆ

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

Bases: ObjectReferenceMixin[SchemaCollection]

Represents a reference to a Snowflake schema.

With this schema reference, you can create, update, and fetch information about schemas, as well as perform certain unique actions on them.

Attributes

alertsΒΆ

The AlertCollection of all alerts contained in this schema.

Examples

Getting all alerts in my_schema:

>>> my_db.schemas["my_schema"].alerts
Copy
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
Copy
databaseΒΆ

The DatabaseResource this schema 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
Copy
event_tablesΒΆ

The EventCollection of all events contained in this schema.

Examples

Getting all events in my_schema:

>>> my_db.schemas["my_schema"].events
Copy
functionsΒΆ

The FunctionCollection of all functions contained in this schema.

Examples

Getting all functions in my_schema:

>>> my_db.schemas["my_schema"].functions
Copy
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
Copy
notebooksΒΆ

The NotebookCollection of all notebooks contained in this schema.

Examples

Getting all notebooks in my_schema:

>>> my_db.schemas["my_schema"].notebooks
Copy
pipesΒΆ

The PipesCollection of all pipes in this schema.

Examples

Getting all pipes in my_schema:

>>> my_db.schemas["my_schema"].pipes
Copy
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"]
Copy
rootΒΆ
servicesΒΆ

The ServiceCollection of all services contained in this schema.

Examples

Getting all services in my_schema:

>>> my_db.schemas["my_schema"].services
Copy
stagesΒΆ

The StageCollection of all stages contained in this schema.

Examples

Getting all stages in my_schema:

>>> my_db.schemas["my_schema"].stages
Copy
streamsΒΆ

The StreamCollection of all streams contained in this schema.

Examples

Getting all streams in my_schema:

>>> my_db.schemas["my_schema"].streams
Copy
tablesΒΆ

The TableCollection of all tables contained in this schema.

Examples

Getting all tables in my_schema:

>>> my_db.schemas["my_schema"].tables
Copy
tasksΒΆ

The TaskCollection of all tasks contained in this schema.

Examples

Getting all tasks in my_schema:

>>> my_db.schemas["my_schema"].tasks
Copy
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
Copy
viewsΒΆ

The ViewCollection of all views contained in this schema.

Examples

Getting all views in my_schema:

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

Methods

create_or_alter(schema: ModelSchemaModel) β†’ 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"))
Copy
create_or_update(schema: ModelSchemaModel) β†’ SchemaResourceΒΆ

Create, or update-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_update(Schema("my_new_schema"))
The `create_or_update` method is deprecated; use `create_or_alter` instead.
Copy
delete(if_exists: bool | None = None) β†’ NoneΒΆ

Delete 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

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

>>> schema_reference.delete()
Copy

Deleting a schema using its reference, if it exists:

>>> schema_reference.delete(if_exists=True)
The `delete` method is deprecated; use `drop` instead.
Copy
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()
Copy

Dropping a schema using its reference, if it exists:

>>> schema_reference.drop(if_exists=True)
Copy
fetch() β†’ ModelSchemaModelΒΆ

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)
Copy
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()
Copy