Skip to main content

Prefixed UUIDs for Python with Pydantic & SQLAlchemy support.

Project description

Logo: pUUID - Prefixed UUIDs for Python

pUUID - Prefixed UUIDs for Python with Pydantic & SQLAlchemy support.

repository mirror License: LGPLv3 pipeline status coverage report Code style: black Imports: isort

pkgversion versionsupport Downloads Week Downloads Total


If you find the pUUID library beneficial, please consider supporting the project by starring it on GitHub.

GitHub Repo stars

pUUID - Prefixed UUIDs for Python

Features

  • Human-Friendly UUIDs: user_019b956e... instead of just 019b956e...
  • All UUID versions from RFC 9562.
  • Pydantic support. (Read more)
  • SQLAlchemy support. (Read more)
  • Strong type guarantees!

Installation

pip install pUUID

# For SQLAlchemy support:
pip install 'pUUID[sqlalchemy]'

Usage

Define a domain-specific ID by inheriting from a versioned base:

from typing import Literal
from puuid import PUUIDv7

class UserUUID(PUUIDv7[Literal["user"]]):
    _prefix = "user"

# Generation
uid = UserUUID()
print(uid) # user_019b956e-ed25-70db-9d0a-0f30fb9047c2

# Deserialization
uid = UserUUID.from_string("user_019b956e-ed25-70db-9d0a-0f30fb9047c2")

Resources

Alternatives

If you only need lexicographically sortable IDs and want to build the SQLAlchemy support yourself, these two projects might be for you:

  • TypeID - pUUID supports all UUID versions because it uses Python’s standard uuid library for UUID generation, while TypeID uses a custom generator that comes with performance improvements but only supports UUIDv7. TypeID does not support SQLAlchemy out of the box.
  • UPID - UPID implements a modified version of the ULID standard, which was designed before UUIDv7 was available. UPID does not support SQLAlchemy out of the box.

Sponsor

Digon.IO GmbH Logo

Digon.IO provides dev & data end-to-end consulting for SMEs and software companies. (Website) (Technical Blog)

The sponsor logo is the property of Digon.IO GmbH. Standard trademark and copyright restrictions apply to any use outside this repository.

License

  • Library source code: Licensed under LGPLv3.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

puuid-1.0.0.tar.gz (6.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

puuid-1.0.0-py3-none-any.whl (7.1 kB view details)

Uploaded Python 3

File details

Details for the file puuid-1.0.0.tar.gz.

File metadata

  • Download URL: puuid-1.0.0.tar.gz
  • Upload date:
  • Size: 6.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.8

File hashes

Hashes for puuid-1.0.0.tar.gz
Algorithm Hash digest
SHA256 6ce27328865d2ee45a43cfc96299e969b88afccb3b925dc2256d26aa1ac3dc87
MD5 05a713afdeef1cac40ec9ddce4b71966
BLAKE2b-256 0dab9b79d471174c4d5b8925446edb1355848c427b88e4be72a9a6ac89576b98

See more details on using hashes here.

File details

Details for the file puuid-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: puuid-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 7.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.8

File hashes

Hashes for puuid-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 32a9ecaf23c4b4ce7221a33ab1c6f73393c43f93992b6e47a0576515d413c929
MD5 2021c7b302fd15b497aa8db1112ecf1d
BLAKE2b-256 a2b88c3e54ba25f38b98f11e0c27f01b5d24d3d6253724c52550dc3ce095a72e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page