Repository navigation
First Check
Commit to Help
Example CodeOriginal: class User(UserBase, table=True):
id: uuid.UUID = Field(
sa_column=Column(UUIDC, primary_key=True, default=uuid.uuid4),
)Modified, modified to work properly: from sqlalchemy import Uuid, Column
UUIDC = Uuid(as_uuid=False)
# Database model, database table inferred from class name
class User(UserBase, table=True):
id: uuid.UUID = Field(
sa_column=Column(UUIDC, primary_key=True, default=uuid.uuid4),
)So, my question is: Is this the right tweak? DescriptionI want to use mysql, and also use uuid for the primary key. I have adapted the engine to mysql+pymysql. and started it successfully, but after starting it, accessing the front-end gives me the following error. Operating SystemLinux Operating System DetailsUbuntu 24.04 Python Version3.10 Additional ContextNo response |
Answered by
elau1004
Mar 31, 2025
Replies: 1 comment
|
You may have a use case for it but is your application globally distributed where a centralized generation of a unique ID for the primary key will be a bottleneck? |
0 replies
Answer selected by
east4ming
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You may have a use case for it but is your application globally distributed where a centralized generation of a unique ID for the primary key will be a bottleneck?
If your answer is NO, I suggests not to use
UUID. AnIDENTITYis much easier to work with. On a straight sprint, comparing 4 bytes ofINT32is going to be 4X faster than comparing 16 bytes ofUUID.