{{ message }}
SQLModel Dynamic Creation with Multiple Inheritance Issue #1638
Replies: 1 comment
0 replies
Answer selected by
Louisfrn
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment

The exception is telling you that the factory is creating a second ORM mapping for the same
(schema, table_name)inside the sameMetaData. That is different from the database table already existing: SQLAlchemy normally expects one in-memoryTableidentity per name in aMetaDatacollection.I would not use
extend_existing=Trueto make repeated model-class creation the normal path. It can merge newTable(...)arguments into the existing metadata object, but it does not turn two separately generated ORM classes into one coherent mapping, and it does not migrate the physical database schema. SQLAlchemy documents that distinction here:https://docs.sqlalchemy.org/en/20/core/metadata.html#sqlal…