Snowflake Legacy ID Generation

1.0.2 · deprecated · verified Thu Apr 09

The `snowflake-legacy` package (current version 1.0.2) is a transitional Python library providing limited backward compatibility for users of the *original* `snowflake` PyPI package, which has since been renamed to `snowflake-uuid`. The original package was designed for generating persistent, machine-specific UUIDs (often referred to as 'snowflakes'). This `snowflake-legacy` package itself is deprecated, primarily serving as a temporary bridge after the `snowflake` PyPI name was transferred to Snowflake, Inc. Users are strongly advised to migrate to `snowflake-uuid` for continued functionality and support. It has an effectively abandoned release cadence.

Warnings

Install

Imports

Quickstart

Demonstrates how to use the `snowflake-legacy` package to read a machine's snowflake ID. Note that this package does not generate IDs; it only reads them, typically from `/etc/snowflake`, which would usually be created by the `snowflake-uuid` package. It will raise a `FileNotFoundError` if the ID file doesn't exist. The `make_snowflake()` function is explicitly disabled.

import snowflake
import os

# This package only *reads* a snowflake ID from a file, typically /etc/snowflake.
# It does NOT generate one. For generation, use 'snowflake-uuid'.
# The ID is usually created by the 'snowflake-uuid' package upon installation.
# This example attempts to read it, but will raise FileNotFoundError if not present.

try:
    # Attempt to read the machine's snowflake ID
    # In a real scenario, this would likely read from /etc/snowflake
    # after the `snowflake-uuid` package has been installed and created it.
    # For demonstration, we use a temporary file path if /etc/snowflake isn't available.
    snowflake_id = snowflake.snowflake(os.environ.get('SNOWFLAKE_ID_PATH', '/etc/snowflake'))
    print(f"Machine Snowflake ID: {snowflake_id}")
except FileNotFoundError:
    print("No snowflake ID found. The 'snowflake-legacy' package only reads IDs; it does not generate them.")
    print("Please install 'snowflake-uuid' package (pip install snowflake-uuid) to generate an ID.")
except NotImplementedError as e:
    print(f"Error: {e}")
except Exception as e:
    print(f"An unexpected error occurred: {e}")

view raw JSON →