Relative Content

Tag Archive for pythonsqlalchemy

How do I reuse columns between tables in SQLAlchemy 2?

I have some very common columns I’d like to share between different tables, but no special relationships between them. For example “created_at”. I think the right approach is concrete table inheritance but I’m not sure.
The base class would be there only for code-reuse, and will not have its own table.
This is all assuming I’m using the type-annotated sqlalchemy 2.0 approach, e.g. perhaps do something like that (see below). What is the right approach?