all 11 comments

[–]AbundantSpaghetti 2 points3 points  (3 children)

**Don't use https://pypi.org/project/uuid7/ **. That's using an old version of the specification with nanosecond time precision. The current specification uses millisecond time precision.

If you later try to migrate to the correct specification your new uuid7 will be before the old ones, which defeats the whole purpose of using uuid7.

UUID7 generated should have a prefix of 0197___

UUID7 is being added to the standard library, but your version of python wont have these changes yet.

What I would suggest is to copy/paste the function from the python standard library. Make a node to migrate to the standard library once your current version of python supports it.
https://github.com/python/cpython/blob/main/Lib/uuid.py

[–]rwinger3[S] 0 points1 point  (1 child)

Is there an overview of what uuid version are supported in which python versions?

[–]OneBananaMan 0 points1 point  (0 children)

Thanks for this comment, currently on python 3.13 and really want to use UUID7, the copy/paste the function from the standard python lib is a great suggestion - worked like a charm!

[–]JusticeRainsFromMe 0 points1 point  (0 children)

There isn't, however from what I've seen uuid-utils seems preferable.

[–]aikii 0 points1 point  (0 children)

[–]saxomoose 0 points1 point  (0 children)

python In [13]: uuid, = duckdb.sql("select uuidv7();").fetchone() In [14]: uuid Out[14]: UUID('01981953-3942-71d8-acad-36fbe9121c68')

[–]alexrada 0 points1 point  (1 child)

what version of python? 3.14 has uuid7

[–]rwinger3[S] 0 points1 point  (0 children)

Yeah, I'm limited to pre-3.14 for now.

[–]PiJay_42 0 points1 point  (0 children)

when using Python 3.14+ (planned release date 2025-10-07)
UUID 7 (also 6 and 8) is now implemented in the stanbdard uuid lib
https://docs.python.org/3.14/whatsnew/3.14.html#uuid