{"id":1714,"library":"snowflake-core","title":"Snowflake Python API for Resource Management (snowflake-core)","description":"The `snowflake-core` library is a Python API that provides programmatic access to Snowflake entity metadata and allows for interaction with Snowflake resources. It enables users to create, delete, and modify Snowflake objects using Python, offering similar functionality to Snowflake's SQL command API. The library is currently at version 1.12.0 and is actively maintained with regular releases.","status":"active","version":"1.12.0","language":"en","source_language":"en","source_url":"https://developers.snowflake.com/python-apis/","tags":["snowflake","cloud","database","api","resource-management","etl"],"install":[{"cmd":"pip install snowflake-core","lang":"bash","label":"Install with pip"}],"dependencies":[{"reason":"Requires Python 3.10 or newer.","package":"Python","optional":false},{"reason":"Required for establishing a connection to Snowflake if not using Snowpark.","package":"snowflake-connector-python","optional":true},{"reason":"Required for establishing a Snowpark session to Snowflake if not using snowflake-connector-python.","package":"snowflake-snowpark-python","optional":true}],"imports":[{"note":"The primary entry point for managing Snowflake objects.","symbol":"Root","correct":"from snowflake.core import Root"},{"note":"Used to create a SnowflakeConnection object for initializing Root.","symbol":"connect","correct":"from snowflake.connector import connect"},{"note":"Used to create a Snowpark Session object for initializing Root.","symbol":"Session","correct":"from snowflake.snowpark import Session"}],"quickstart":{"code":"import os\nfrom snowflake.connector import connect\nfrom snowflake.snowpark import Session\nfrom snowflake.core import Root\n\n# Option 1: Create Root instance from Snowflake Connection\nconnection_params = {\n    \"account\": os.environ.get(\"SNOWFLAKE_ACCOUNT\", \"\"),\n    \"user\": os.environ.get(\"SNOWFLAKE_USER\", \"\"),\n    \"password\": os.environ.get(\"SNOWFLAKE_PASSWORD\", \"\"),\n    \"database\": os.environ.get(\"SNOWFLAKE_DATABASE\", \"test_db\"),\n    \"warehouse\": os.environ.get(\"SNOWFLAKE_WAREHOUSE\", \"test_wh\"),\n    \"schema\": os.environ.get(\"SNOWFLAKE_SCHEMA\", \"public\"),\n}\n\n# Ensure required environment variables are set\nif not all(connection_params.values()):\n    print(\"Warning: Some Snowflake connection parameters are missing. Please set SNOWFLAKE_ACCOUNT, SNOWFLAKE_USER, and SNOWFLAKE_PASSWORD environment variables.\")\n    # Exit or handle error if connection is critical\n\ntry:\n    # Using snowflake.connector\n    connection = connect(**connection_params)\n    root_from_conn = Root(connection)\n    print(f\"Root instance created from SnowflakeConnection: {root_from_conn}\")\n\n    # Example: Accessing a database collection\n    # Assuming 'mydatabase' exists or will be created\n    # my_database = root_from_conn.databases[\"MYDATABASE\"]\n    # print(f\"Accessed database: {my_database}\")\n\n    connection.close()\n\n    # Option 2: Create Root instance from Snowpark Session\n    # Ensure required environment variables are set for Snowpark as well if different\n    session = Session.builder.configs(connection_params).create()\n    root_from_session = Root(session)\n    print(f\"Root instance created from Snowpark Session: {root_from_session}\")\n\n    # Example: Accessing a compute pool collection\n    # compute_pools = root_from_session.compute_pools\n    # print(f\"Accessed compute pools collection: {compute_pools}\")\n\n    session.close()\n\nexcept Exception as e:\n    print(f\"An error occurred during quickstart: {e}\")","lang":"python","description":"This quickstart demonstrates how to initialize the `Root` object, which is the entry point for managing Snowflake resources, using either a `snowflake.connector.connect` object or a `snowflake.snowpark.Session` object. It highlights the use of environment variables for secure connection parameter management."},"warnings":[{"fix":"Look for a 'View latest version' link or ensure the URL reflects the current version (e.g., `https://docs.snowflake.com/en/developer-guide/python-apis/` and check the version displayed on the page).","message":"Always verify you are consulting the documentation for the latest version of `snowflake-core`. Snowflake's documentation portal might default to older versions, which can lead to confusion regarding available features or API signatures.","severity":"gotcha","affected_versions":"<=1.12.0"},{"fix":"Consult the official documentation on 'Local references vs Snowflake snapshots' to grasp the interaction model and manage performance and cost expectations.","message":"Understand the distinction between local Python objects (references) and actual Snowflake snapshots. Operations that modify or retrieve information from Snowflake generally require explicit calls through the `Root` object and its collections, as Python objects in memory don't automatically sync with the remote state.","severity":"gotcha","affected_versions":"All"},{"fix":"Store Snowflake account, user, password, and other connection details in environment variables (e.g., `SNOWFLAKE_ACCOUNT`, `SNOWFLAKE_USER`, `SNOWFLAKE_PASSWORD`) and retrieve them using `os.environ.get()`.","message":"Connection parameters are typically sensitive and should be managed securely, preferably using environment variables as shown in official examples. Hardcoding credentials directly in code is discouraged.","severity":"gotcha","affected_versions":"All"}],"env_vars":null,"last_verified":"2026-04-09T00:00:00.000Z","next_check":"2026-07-08T00:00:00.000Z"}