I need to generate UUID for MYSQL int and BigInt which needs to be in a given range and I need 10 digits integer UUID for which I have written a code
def getUniqueID():
unique_id = uuid4().int & (0 << 32) - 1
return unique_id
for example, SQL int should not exceed the limit of 2147483647.(unique_id < 2147483647).
def getUniqueID(min,max):
unique_id = uuid4().int & (0 << 32) - 1
return unique_id
SQL int Limitation found here,
First you can install shortuuid with:
python -m pip install shortuuid
then you can use it like this:
import shortuuid
print(shortuuid.ShortUUID().random(length=10))
the project is in github: https://github.com/skorokithakis/shortuuid
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.