snowflake.core.notebook.NotebookCollection | Snowflake Documentation (original) (raw)

class snowflake.core.notebook.NotebookCollection(schema: SchemaResource)

Bases: SchemaObjectCollectionParent[NotebookResource]

Represents the collection operations of the Snowflake Notebook resource.

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

Examples

Creating a notebook instance:

notebooks = root.databases["my_db"].schemas["my_schema"].notebooks new_notebook = Notebook( ... name="my_notebook", ... comment="This is a notebook" ... ) notebooks.create(new_notebook)

Attributes

database

The DatabaseResource this collection belongs to.

root

The Root object this collection belongs to.

Methods

create(notebook: Notebook, *, mode: CreateMode = CreateMode.error_if_exists) → NotebookResource

Create a notebook in Snowflake.

Parameters:

Examples

Creating a notebook in Snowflake and getting the reference to it:

notebook = Notebook( ... name="my_notebook", ... version="notebook_ver1", ... comment="This is a notebook" ... )

Use the notebook collection created before to create a reference to the notebook resource

in Snowflake.

notebook_reference = notebook_collection.create(notebook)

create_async(notebook: Notebook, *, mode: CreateMode = CreateMode.error_if_exists) → PollingOperation[NotebookResource]

An asynchronous version of create().

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

items() → ItemsView[str, T]

iter(*, like: str | None = None, starts_with: Annotated[str, Strict(strict=True)] | None = None, show_limit: Annotated[int, FieldInfo(annotation=NoneType, required=True, metadata=[Strict(strict=True), Ge(ge=1), Le(le=10000)])] | None = None, from_name: Annotated[str, Strict(strict=True)] | None = None) → Iterator[Notebook]

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

Parameters:

Examples

Showing all notebooks that you have access to see:

notebooks = notebook_collection.iter()

Showing information of the exact notebook you want to see:

notebooks = notebook_collection.iter(like="your-notebook-name")

Showing notebooks starting with ‘your-notebook-name’:

notebooks = notebook_collection.iter(like="your-notebook-name%")

Using a for-loop to retrieve information from iterator:

for notebook in notebooks: ... print(notebook.name, notebook.version, notebook.user_packages)

iter_async(*, like: str | None = None, starts_with: Annotated[str, Strict(strict=True)] | None = None, show_limit: Annotated[int, FieldInfo(annotation=NoneType, required=True, metadata=[Strict(strict=True), Ge(ge=1), Le(le=10000)])] | None = None, from_name: Annotated[str, Strict(strict=True)] | None = None) → PollingOperation[Iterator[Notebook]]

An asynchronous version of iter().

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

keys() → KeysView[str]

values() → ValuesView[T]