Skip to main content

notebooks

Creates, updates, deletes, gets or lists a notebooks resource.

Overview

Namenotebooks
TypeResource
Idsnowflake.notebook.notebooks

Fields

NameDatatypeDescription
namestringName of the notebook
budgetstringName of the budget if the notebook is monitored by a budget
commentstringuser comment associated to an object in the dictionary
compute_poolstringCompute pool name where the snowservice runs
created_onstringDate and time when the notebook was created.
database_namestringDatabase in which the notebook is stored
default_packagesstringDefault packages of the notebook
default_versionstringThe default version name of a file based entity.
default_version_detailsobjectThe version details of a file based entity
external_access_integrationsarrayList of external access integrations attached to this function
external_access_secretsstringSecrets to be used with this function for external access
fromLocationstringLocation to copy the file from. This must be a Snowflake stage location.
idle_auto_shutdown_time_secondsintegerSets the time in seconds for when to shutdown an idle Notebook.
import_urlsarrayList of urls
last_version_detailsobjectThe version details of a file based entity
live_version_location_uristringThe current version location
main_filestringName + path of the file for the Notebook
ownerstringRole that owns the notebook
owner_role_typestringThe type of role that owns the notebook
query_warehousestringWarehouse against which the queries issued by the Streamlit app are run against
runtime_namestringThe runtime to run the Streamlit or Notebook on. If this is not set, the warehouse is assumed
schema_namestringSchema in which the notebook is stored
titlestringUser facing title of the Streamlit app or an Organization Profile
url_idstringUnique ID associated with the notebook object.
user_packagesstringUser packages of the notebook
versionstringUser specified version alias

Methods

NameAccessible byRequired ParamsOptional ParamsDescription
fetch_notebookSELECTdatabase_name, name, schema_name, endpoint-Fetch a notebook
list_notebooksSELECTdatabase_name, schema_name, endpointlike, startsWith, showLimit, fromNameList notebooks
create_notebookINSERTdatabase_name, schema_name, data__name, endpointcreateModeCreate a notebook
delete_notebookDELETEdatabase_name, name, schema_name, endpointifExistsDelete a notebook
add_live_version_notebookEXECdatabase_name, name, schema_name, endpointfromLast, commentAdds a LIVE version to the notebook
commit_notebookEXECdatabase_name, name, schema_name, endpointversion, commentIf a Git connection is set up for the notebook, commits the LIVE version of the notebook to the Git repository
execute_notebookEXECdatabase_name, name, schema_name, endpointasyncExecExecute a Notebook
rename_notebookEXECdatabase_name, name, schema_name, targetName, endpointifExists, targetDatabase, targetSchemaChanges the name of the notebook to new name. The new identifier must be unique for the schema.

Optional Parameter Details
NameDescriptionTypeDefault
asyncExecAsynchronous execution enable/disable. Default is disable.booleanfalse
commentSets a comment for the notebook or version of the notebookstring-
createModeQuery parameter allowing support for different modes of resource creation. Possible values include: - errorIfExists: Throws an error if you try to create a resource that already exists. - orReplace: Automatically replaces the existing resource with the current one. - ifNotExists: Creates a new resource when an alter is requested for a non-existent resource.stringerrorIfExists
fromLastSets the LIVE version to the LAST version of the notebookboolean-
fromNameQuery 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.string-
ifExistsQuery 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.booleanfalse
likeQuery parameter to filter the command output by resource name. Uses case-insensitive pattern matching, with support for SQL wildcard characters.string-
showLimitQuery parameter to limit the maximum number of rows returned by a command.integer-
startsWithQuery 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.string-
targetDatabaseDatabase of the target resource. Defaults to the source's databasestring-
targetSchemaSchema of the target resource. Defaults to the source's schemastring-
versionlive version of the aliasstring-

SELECT examples

List notebooks

SELECT
name,
budget,
comment,
compute_pool,
created_on,
database_name,
default_packages,
default_version,
default_version_details,
external_access_integrations,
external_access_secrets,
fromLocation,
idle_auto_shutdown_time_seconds,
import_urls,
last_version_details,
live_version_location_uri,
main_file,
owner,
owner_role_type,
query_warehouse,
runtime_name,
schema_name,
title,
url_id,
user_packages,
version
FROM snowflake.notebook.notebooks
WHERE database_name = '{{ database_name }}'
AND schema_name = '{{ schema_name }}'
AND endpoint = '{{ endpoint }}';

INSERT example

Use the following StackQL query and manifest file to create a new notebooks resource.

/*+ create */
INSERT INTO snowflake.notebook.notebooks (
data__name,
data__version,
data__fromLocation,
data__main_file,
data__comment,
data__default_version,
data__query_warehouse,
data__default_version_details,
data__last_version_details,
database_name,
schema_name,
endpoint
)
SELECT
'{{ name }}',
'{{ version }}',
'{{ fromLocation }}',
'{{ main_file }}',
'{{ comment }}',
'{{ default_version }}',
'{{ query_warehouse }}',
'{{ default_version_details }}',
'{{ last_version_details }}',
'{{ database_name }}',
'{{ schema_name }}',
'{{ endpoint }}'
;

DELETE example

Deletes the specified notebooks resource.

/*+ delete */
DELETE FROM snowflake.notebook.notebooks
WHERE database_name = '{{ database_name }}'
AND name = '{{ name }}'
AND schema_name = '{{ schema_name }}'
AND endpoint = '{{ endpoint }}';