2
submitted 3 weeks ago* (last edited 3 weeks ago) by logging_strict@programming.dev to c/python@programming.dev

Will commonly see examples of SQLAlchemy or SQLModel Bases that look like:

class DB1Base(SQLModel, registry=registry()):

There are x10^256 examples of this. And so lets take a step backwards and appreciate the prolific nature of

the guy in charge of random database object names

sqlalchemy docs screams to apply a database object naming convention.

alembic docs has a whole section dedicated it.

So what about SQLModel docs or issues? .... (crickets)

Every example ever lacks applying naming convention to the registry metadata!

from sqlalchemy import MetaData
from sqlalchemy.orm import registry

# copy+paste from the sqlalchemy docs. One case don't wanna be creative.
naming_convention_no_schema = {
    "ix": "ix_%(column_0_label)s",
    "uq": "uq_%(table_name)s_%(column_0_name)s",
    "ck": "ck_%(table_name)s_`%(constraint_name)s`",
    "fk": "fk_%(table_name)s_%(column_0_name)s_%(referred_table_name)s",
    "pk": "pk_%(table_name)s",
}

metadata = MetaData(
        naming_convention=naming_convention_no_schema,
        schema=schema,
)

reg = registry(metadata=metadata)

class DB1Base(SQLModel, registry=reg):

Why not to -- job security!

Can only imagine that folks wanting to give every single database object a name manually would do that as a form of job security. If that is the case then carry on.

For those of us who don't want to micro manage the micro manage of micro managers, would highly suggest not manually explicitly naming each and every database object. In each and every database. Not ever, but almost nearly ever.

For example, what if the guy in charge of random database object names gets a girlfriend? It could happen and what a disaster that would be. For him, for her, and for all the people who have to try to track down why a foreign key or unique constraint doesn't exist when it's clear as day in the code that it should be there.

Might have exaggerated, there is no agency of random database object names. But that won't stop the guy in charge of random database object names. Numerically, he can snap his fingers and poof, that agency will exist. Don't underestimate the power and unflinching resolve of the guy in charge of random database object names

The take away

Every single SQLModel Base ever neglects, when creating a registry, to apply database objects naming convention. This includes the SQLModel source code.

So why not submit a PR? SQLModel seems to be unmaintained. There are 69 PRs in the pipeline. So the options are:

  • wait for hell to start selling ice cream

  • poke fun at it

Only have enough coin for the boat man. So that leaves ...

you are viewing a single comment's thread
view the rest of the comments
[-] onlinepersona@programming.dev 2 points 3 weeks ago* (last edited 3 weeks ago)

This isn't even close to chill, dude. Wow. If you think that tone is going to help, I'm not sure what going through your head. Would you welcome or be convinced by somebody writing like that in your open source project?

Anti Commercial-AI license

[-] logging_strict@programming.dev 1 points 2 weeks ago* (last edited 2 weeks ago)

If only would be so lucky. Truly i don't mind. Here go at

Purposefully do not have any code of conduct for any of my packages. And i have not joined python.org to avoid submitting to a code of conduct.

Everyone is welcome to be themselves. If something hurtful is said, i'll take it in stride without barraging the commenter with Captain obvious sweet nothings.

You troll, i disparage. It's not so different. Except for the two fresh super hero creation stories.

For the love of cosplay and super hero conventions, for a moment could put down those tunnel vision goggles to acknowledge the well written prose. Or not, but that's on you

this post was submitted on 06 Aug 2025
2 points (58.3% liked)

Python

7406 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