A short id based on 8 bytes (it fits in a PostgreSQL BigInt).
Project description
EightID: A (really) short id, that fits in 8 bytes.
EightID
is a short ID that fits in 8 bytes. 4 bytes are dedicated to the timestamp (second resolution) and the other are 4 random bytes.
It's only 8 bytes and as such it fits in a BigInt column.
Installation
Installation using pip:
pip install eightid
Quick intro
>>> from eightid import EightID
>>> short_id = EightID()
# Displays as base64 by default
>>> short_id
<EightID 'AH4jTMKtwrXCr8OQ'>
>>> print(short_id)
AH4jTMKtwrXCr8OQ
>>> short_id.integer
35504659304394704
# Access when the id was created
>>> short_id.datetime
datetime.datetime(2022, 4, 6, 17, 16, 12)
# Access with str() and .string
>>> str(short_id)
'AH4jTMKtwrXCr8OQ'
>>> short_id.string
'AH4jTMKtwrXCr8OQ'
# Recreate the EightID from a string
>>> EightID.from_string(short_id.string)
<EightID 'AH4jTMKtwrXCr8OQ'>
# Or from
>>> EightID.from_int(short_id.integer)
<EightID 'AH4jTMKtwrXCr8OQ'>
Django integration
from eightid import django
class AppModel(models.Model):
id = django.EightIDField(primary_key=True)
License
EightID is licensed under the MIT license (see the LICENSE
file for details).
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
eightid-0.1.1.tar.gz
(4.5 kB
view details)
Built Distribution
File details
Details for the file eightid-0.1.1.tar.gz
.
File metadata
- Download URL: eightid-0.1.1.tar.gz
- Upload date:
- Size: 4.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.13 CPython/3.9.12 Linux/5.13.0-1017-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9b193b0c2269f7bac3b83d4553e784f6acba2e37fc1adf30e5702d6ac7469618 |
|
MD5 | 2c0e62f8133775eeb8f4140305c16752 |
|
BLAKE2b-256 | 8eeee3310304d63df83f49c7027f66821d1fc26e5f98ba98d9e66a3ef0b74431 |
File details
Details for the file eightid-0.1.1-py3-none-any.whl
.
File metadata
- Download URL: eightid-0.1.1-py3-none-any.whl
- Upload date:
- Size: 5.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.13 CPython/3.9.12 Linux/5.13.0-1017-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | fa349f8f25c26e5950321c53560dc24aa1082dcb134c42f73a0a240169475ff4 |
|
MD5 | 716802447e9edab3c72a8ffa5dd7fe20 |
|
BLAKE2b-256 | 5778abe490c37225efc0c41f3d9fc23da2cb0ab7e5a822817581b81ef2893c43 |