Welcome to Python SnowFlake’s documentation!¶
A library that provides snowflake features to python, including Client & Server.
This is extend of https://github.com/koblas/pysnowflake with Client adding.
Installation¶
pip install pysnowflake
Run server¶
snowflake_start_server [--dc=DC_ID] [--worker=WORKER_ID] [--host=ADDRESS] [--port=PORT]
With configuration default value:
- dc (int, 2 bit): be searched in environment PSF_DC first, if not found, get the 0 value.
- worker (int, 8 bit): be searched in environment PSF_WORKER first, if not found, get the 0 value.
- address (domain, inet): default is localhost.
- port (int): default is 8910.
APIs¶
All APIs through http GET method.
API Path | Description |
---|---|
/ | Get/Generate the ID |
/stats | Get the information and statistic for this worker |
How to use?¶
# just import and use it import snowflake.client # One time only initialization >>> snowflake.client.setup(host, port) # Then get the ID whenever you need >>> snowflake.client.get_guid() 3631957913783762945 # See the stats if you want >>> snowflake.client.get_stats() { 'dc': 0, 'worker': 0, 'timestamp': 1416207853020, # current timestamp for this worker 'last_timestamp': 1416207845161, # the last timestamp that generated ID on 'sequence': 12, # the sequence number for last timestamp 'sequence_overload': 1, # the number of times that the sequence is overflow 'errors': 1, # the number of times that clock went backward }