snowflake.core.notebook.NotebookCollection¶
- class snowflake.core.notebook.NotebookCollection(schema: SchemaResource)¶
Bases:
NotebookCollectionBase
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:
notebook (Notebook) – The
Notebook
object that you want to create in Snowflake.mode (CreateMode, optional) –
One of the following strings.
CreateMode.error_if_exists
: Throw ansnowflake.core.exceptions.ConflictError
if the notebook already exists in Snowflake. Equivalent to SQLcreate notebook <name> ...
.CreateMode.or_replace
: Replace if the notebook already exists in Snowflake. Equivalent to SQLcreate or replace notebook <name> ...
.CreateMode.if_not_exists
: Do nothing if the notebook already exists in Snowflake. Equivalent to SQLcreate notebook <name> if not exists...
Default value is
CreateMode.error_if_exists
.
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: str | None = None, limit: int | None = None, from_name: str | None = None, show_limit: int | None = None) Iterator[Notebook] ¶
List notebooks.
- Parameters:
like (str) – Parameter to filter the command output by resource name. Uses case-insensitive pattern matching, with support for SQL wildcard characters.
starts_with (str) – Parameter to filter the command output based on the string of characters that appear at the beginning of the object name. Uses case-sensitive pattern matching.
limit (int) – Parameter to limit the maximum number of rows returned by a command.
from_name (str) – Parameter to enable fetching rows only following the first row whose object name matches the specified string. Case-sensitive and does not have to be the full name.
- iter_async(*, like: str | None = None, starts_with: str | None = None, limit: int | None = None, from_name: str | None = None, show_limit: int | 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] ¶
- update_reference(old_name: str, new_name: str, resource: T) None ¶
Update the collection with a new item.
- values() ValuesView[T] ¶