snowflake.core.task.TaskCollection¶
- class snowflake.core.task.TaskCollection(schema: SchemaResource)¶
- Bases: - SchemaObjectCollectionParent[- TaskResource]- Represents the collection operations of the Snowflake Task resource. - With this collection, you can create, iterate through, and search for task that you have access to in the current context. - Examples - >>> task_collection = root.databases["mydb"].schemas["myschema"].tasks >>> task = Task(name="mytask", definition="select 1") >>> task_collection.create(task) - Attributes - database¶
- The DatabaseResource this collection belongs to. 
 - root¶
- The Root object this collection belongs to. 
 - Methods - create(task: Task, *, mode: CreateMode = CreateMode.error_if_exists) TaskResource¶
- Create a task in Snowflake. - Parameters:
- task (an instance of - Task.)
- mode (CreateMode, optional) – - One of the following strings. - CreateMode.error_if_exists: Throw an- snowflake.core.exceptions.ConflictErrorif the task already exists in Snowflake. Equivalent to SQL- create task <name> ....- CreateMode.or_replace: Replace if the task already exists in Snowflake. Equivalent to SQL- create or replace task <name> ....- CreateMode.if_not_exists: Do nothing if the task already exists in Snowflake. Equivalent to SQL- create task <name> if not exists...- Default value is - CreateMode.error_if_exists.
 
 - Examples - Creating a task in Snowflake and getting a reference to it: - >>> task_parameters = Task(name="mytask", definition="select 1") >>> # Use the task collection created before to create a reference to the task resource >>> # in Snowflake. >>> task_reference = task_collection.create(task_parameters) 
 - create_async(task: Task, *, mode: CreateMode = CreateMode.error_if_exists) PollingOperation[TaskResource]¶
- An asynchronous version of - create().- Refer to - PollingOperationfor 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, root_only: bool = False) Iterator[Task]¶
- Iterate through - Taskobjects in Snowflake, filtering on any optional- likepattern.- Parameters:
- like (str, optional) – A case-insensitive string functioning as a filter, with support for SQL wildcard characters (% and _). 
- starts_with (str, optional) – String used to filter the command output based on the string of characters t 
- limit (int, optional) – Limit of the maximum number of rows returned by iter(). The default is - None, which behaves equivalently to show_limit=10000. This value must be between- 1and- 10000.
- from_name (str, optional) – Fetch rows only following the first row whose object name matches the specified string. This is case-sensitive and does not have to be the full name. 
- root_only (bool, optional) – Look for root tasks only. Default is - False.
 
 - Examples - Showing all tasks that you have access to see: - >>> tasks = task_collection.iter() - Showing information of the exact task you want to see: - >>> tasks = task_collection.iter(like="your-task-name") - Showing tasks starting with ‘your-task-name-‘: - >>> tasks = task_collection.iter(like="your-task-name-%") - Using a for loop to retrieve information from iterator: - >>> for task in tasks: ... print(task.name, task.comment) 
 - iter_async(*, like: str | None = None, starts_with: str | None = None, limit: int | None = None, from_name: str | None = None, root_only: bool = False) PollingOperation[Iterator[Task]]¶
- An asynchronous version of - iter().- Refer to - PollingOperationfor 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]¶