There are countless issues here. They didn’t do exception handling, they used a string to store their UUIDs (even if this was a DB constraint, you use sqlalchemy.Uuid and let the ORM and DB handle the translation), and as the person you’re replying to stressed, they’re using non-monotonic UUIDs. Also if you have a unique user_id and you’re never exposing your primary keys, you don’t need to get fancy, just let the ORM handle it with auto-incrementing, for most use cases. And so many other tragic things about this one tiny blog post.
tl;dr if you’re going to copy code you don’t understand, copy it from the docs, not from everything in the kitchen thrown into a blender.
There are countless issues here. They didn’t do exception handling, they used a string to store their UUIDs (even if this was a DB constraint, you use
sqlalchemy.Uuid
and let the ORM and DB handle the translation), and as the person you’re replying to stressed, they’re using non-monotonic UUIDs. Also if you have a uniqueuser_id
and you’re never exposing your primary keys, you don’t need to get fancy, just let the ORM handle it with auto-incrementing, for most use cases. And so many other tragic things about this one tiny blog post.tl;dr if you’re going to copy code you don’t understand, copy it from the docs, not from everything in the kitchen thrown into a blender.