### Load Snowflake Generator State Source: https://github.com/vd2org/snowflake/blob/master/README.md Illustrates how to initialize a SnowflakeGenerator with the state derived from an existing Snowflake ID. This is achieved by first parsing the Snowflake ID using Snowflake.parse() and then passing the resulting Snowflake object to the SnowflakeGenerator.from_snowflake() class method. ```Python from snowflake import SnowflakeGenerator, Snowflake sf = Snowflake.parse(856165981072306191, 1288834974657) gen = SnowflakeGenerator.from_snowflake(sf) for i in range(100): val = next(gen) print(val) ``` -------------------------------- ### Generate Snowflake IDs Source: https://github.com/vd2org/snowflake/blob/master/README.md Demonstrates how to use the SnowflakeGenerator class to generate a sequence of unique Snowflake IDs. An instance of SnowflakeGenerator is created with a given worker ID, and then IDs are generated iteratively using the next() method. ```Python from snowflake import SnowflakeGenerator gen = SnowflakeGenerator(42) for i in range(100): val = next(gen) print(val) ``` -------------------------------- ### Parse Snowflake ID Source: https://github.com/vd2org/snowflake/blob/master/README.md Shows how to parse a Snowflake ID into its constituent components such as timestamp, instance, epoch, sequence number, seconds, milliseconds, and datetime. The Snowflake.parse() method is used, requiring the ID and the epoch timestamp. ```Python from snowflake import Snowflake sf = Snowflake.parse(856165981072306191, 1288834974657) print(f"{sf.timestamp = }") print(f"{sf.instance = }") print(f"{sf.epoch = }") print(f"{sf.seq = }") print(f"{sf.seconds = }") print(f"{sf.milliseconds = }") print(f"{sf.datetime = }") print(f"{int(sf) = }") ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.