this post was submitted on 04 Jul 2025
13 points (100.0% liked)

Python

7285 readers
1 users here now

Welcome to the Python community on the programming.dev Lemmy instance!

๐Ÿ“… Events

PastNovember 2023

October 2023

July 2023

August 2023

September 2023

๐Ÿ Python project:
๐Ÿ’“ Python Community:
โœจ Python Ecosystem:
๐ŸŒŒ Fediverse
Communities
Projects
Feeds

founded 2 years ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
[โ€“] [email protected] 2 points 1 week ago* (last edited 1 week ago)

pydantic underneath (pydantic-base) is written in Rust. fastapi is fast cuz of pydantic. fastapi is extremely popular. Cuz it's right there in the word, fast. No matter how crap the usability is, the word fast will always win.

If fastapi is fast then whatever is not fastapi is slow. And there is no convincing anyone otherwise so lets not even try.

Therefore lets do fast. Cuz we already agreed slow would be bad.

normal dataclasses is not fast and therefore it's bad. If it had a better marketing team this would be a different conversation.

SQLModel combines pydantic and SQLAlchemy.

At first i feel in love with the SQLModel docs. Then realized the eye wateringly beautiful docs are missing vital details, such as how to:

  1. create a Base without also creating a Model table

  2. overload __tablename__ algo from the awful default cls.__name__.lower()

  3. support multiple databases each containing the same named table

#2 is particularly nasty. SQLModel.__new__ implementation consists of multiple metaclasses. So subclasses always inherit that worthless __tablename__ implementation. And SQLAlchemy applies three decorators, so figuring out the right witchcraft to create the Descriptor is near impossible. pydantic doesn't support overriding __tablename__

Then i came along

After days of, lets be honest, hair loss and bouts of heavy drinking, posted the answer here.

Required familiarity with pydantic, sqlalchemy, and SQLModel.