Snowflake Python APIs: Managing Snowflake objects with Python (original) (raw)

The Snowflake Python APIs package is a unified library that seamlessly connects Python with Snowflake workloads. It is intended to provide comprehensive APIs for interacting with Snowflake resources across data engineering, Snowpark, Snowpark ML, and application workloads using a first-class Python API.

You can use the Snowflake Python APIs to manage Snowflake resources by creating, dropping, or altering them, and more. You can use Python to perform tasks you might otherwise perform with Snowflake SQL commands.

To learn more about the API, including its general concepts and design patterns, see Snowflake Python APIs: General concepts.

Supported Snowflake resource objects

Note

The API reference documentation reflects the latest version of the Snowflake Python APIs. Note that not all resources in the API currently provide 100% coverage of their equivalent SQL commands, but the Python APIs are under active development and are continuously expanding.

With the Snowflake Python APIs, you can currently manage the following Snowflake resource objects:

Python ecosystem in Snowflake

The Snowflake Python APIs, the Snowpark API for Python, and theSnowflake Connector for Python are interfaces that each have distinct purposes in Snowflake. This section explains their differences and describes the typical use cases for each.

Snowflake Python APIs

You can use this set of first-class Python APIs to define and manage core resources (such as tables, warehouses, and tasks) across Snowflake workloads. Unlike the Python Connector, these APIs interact with Snowflake using native Python without the need to use SQL.

The Snowflake Python APIs package unifies all Snowflake Python libraries (including connector, core, snowpark, andml) so that you can simply start with the command pip install snowflake.

Following the declarative programming approach, this API can be used as a DevOps tool to manage changes to your resources and automate code and infrastructure deployment in Snowflake.

Snowpark

This set of libraries and code execution environments can run Python and other programming languages next to your data in Snowflake.

Snowflake Connector for Python

Use this SQL driver to connect to Snowflake, execute SQL statements, and then get the results using a Python client.

With the Python Connector, you write all of your interactions with Snowflake using SQL statement strings.

Get started with the Snowflake Python APIs

To get started with the Snowflake Python APIs, see the instructions in the following topics:

  1. Install the library.
  2. Connect to Snowflake.

For tutorials on getting started with the Snowflake Python APIs, see Tutorials: Getting started with the Snowflake Python APIs.

Supported Python versions

The supported versions of Python are:

Developer guides

Guide Description
Install the Snowflake Python APIs library Install the Snowflake Python APIs package.
Connect to Snowflake with the Snowflake Python APIs Connect to Snowflake from Python code.
Managing Snowflake accounts and managed accounts with Python Use the API to create and manage accounts and managed accounts.
Managing Snowflake alerts with Python Use the API to create and manage alerts.
Managing data loading and unloading resources with Python Use the API to create and manage data loading and unloading resources, including external volumes, pipes, and stages.
Managing Snowflake databases, schemas, tables, and views with Python Use the API to create and manage databases, schemas, and tables.
Managing Snowflake dynamic tables with Python Use the API to create and manage dynamic tables.
Managing Snowflake functions and stored procedures with Python Use the API to create and manage user-defined functions (UDFs) and stored procedures.
Managing Snowflake integrations with Python Use the API to create and manage catalog integrations and notification integrations.
Managing Snowflake network policies with Python Use the API to create and manage network policies.
Managing Snowflake Notebooks with Python Use the API to create and manage Snowflake Notebooks.
Managing Snowpark Container Services (including service functions) with Python Use the API to manage components of Snowpark Container Services, including compute pools, image repositories, services, and service functions.
Managing Snowflake streams with Python Use the API to create and manage streams.
Managing Snowflake tasks and task graphs with Python Use the API to create, execute, and manage tasks and task graphs.
Managing Snowflake users, roles, and grants with Python Use the API to create and manage users, roles, and grants.
Managing Snowflake virtual warehouses with Python Use the API to create and manage virtual warehouses.

References

Snowflake Python APIs Reference

Costs of Snowflake access

To reduce costs—–for both usage credit and network activity—–the Snowflake Python APIs are designed to communicate with Snowflake only when you call methods designed to synchronize with Snowflake.

Objects in the API are either local references (or handles) or snapshots of state stored on Snowflake. In general, when you process information that was retrieved from Snowflake, you do so through a local, in-memory reference object.

These references do not synchronize with Snowflake until you call a method. When you call a method, you are usually incurring costs in both usage credit and network activity. In contrast, when you work with in-memory references, such as when accessing attributes, your work is performed locally and incurs no such costs.