{"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":"python","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,"search_vec":"'1.12.0':61 'access':22 'activ':64 'allow':28 'api':3,18,54,72 'cloud':70 'command':53 'core':9,13 'creat':38 'current':58 'databas':71 'delet':39 'enabl':35 'entiti':25 'etl':76 'function':48 'interact':30 'librari':14,56 'maintain':65 'manag':6,75 'metadata':26 'modifi':41 'object':43 'offer':46 'programmat':21 'provid':20 'python':2,17,45 'regular':67 'releas':68 'resourc':5,33,74 'resource-manag':73 'similar':47 'snowflak':1,8,12,24,32,42,50,69 'snowflake-cor':7,11 'sql':52 'use':44 'user':36 'version':60","created_at":"2026-04-09T03:59:59.042297+00:00","updated_at":"2026-04-16T21:53:38.711630+00:00","problems":[{"fix":"pip install snowflake-core","cause":"The 'snowflake-core' library is not installed in the current Python environment.","error":"ModuleNotFoundError: No module named 'snowflake.core'"},{"fix":"Double-check all connection parameters in the `configs` dictionary or ensure environment variables (e.g., `SNOWFLAKE_ACCOUNT`, `SNOWFLAKE_USER`, `SNOWFLAKE_PASSWORD`) are correctly set.","cause":"The provided connection parameters (username, password, account, etc.) are incorrect or incomplete when establishing the Snowflake session.","error":"snowflake.connector.errors.ProgrammingError: Failed to connect to DB: Invalid username or password."},{"fix":"Use `session.sql(\"YOUR_SQL_QUERY\").collect()` or `session.sql(\"YOUR_SQL_QUERY\").to_dataframe()` to execute SQL.","cause":"The `snowflake-core` `Session` object uses the `.sql()` method to run SQL queries, not a direct `.execute()` method like `snowflake-connector-python`'s cursor.","error":"AttributeError: 'Session' object has no attribute 'execute'"},{"fix":"Grant the required privileges to the role in Snowflake using SQL, for example: `GRANT CREATE TABLE ON SCHEMA MY_DB.MY_SCHEMA TO ROLE MY_ROLE;`","cause":"The Snowflake role associated with the current session lacks the necessary privileges to perform the requested DDL/DML operation.","error":"snowflake.connector.errors.ProgrammingError: SQL compilation error: Role 'MY_ROLE' does not have sufficient privileges to perform operation 'CREATE TABLE' on schema 'MY_DB.MY_SCHEMA'."}],"ecosystem":"pypi","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":"1.13.1","cli_name":"","cli_version":null,"type":"library","homepage":"https://www.snowflake.com","github":null,"docs":null,"changelog":null,"pypi":"https://pypi.org/project/snowflake-core/","npm":null,"openapi_spec":null,"status_page":null,"smithery":null,"categories":["database","aws","gcp","azure"],"base_url":null,"auth_type":null,"provenance":{"verified_status":"passing","verified_at":"2026-06-28","last_verified":"2026-08-27","next_check":"2026-07-28","install_tag":null}}