First Check
Commit to Help
Example CodeExample code from the blog:
Base = declarative_base()
class MyTableClass(Base):
__tablename__ = 'myTableName'
myFirstCol = Column(Integer, primary_key=True)
mySecondCol = Column(Integer, primary_key=True)
Base.metadata.create_table(engine)
attr_dict = {'__tablename__': 'myTableName',
'myFirstCol': Column(Integer, primary_key=True),
'mySecondCol': Column(Integer)}DescriptionI am looking if SQLModel supports dynamic schema like SQLAlchemy does. Example: https://sparrigan.github.io/sql/sqla/2016/01/03/dynamic-tables.html Operating SystemmacOS Operating System DetailsNo response SQLModel Version0.0.4 Python Version3.9.0 Additional ContextNo response |
Replies: 3 comments
|
I was able to achieve this with the below workaround.
The only thing I am facing is a warning. When you call I feel this can be ignored. @tiangolo can you please confirm? |
|
This would be technically not supported by SQLModel, as the idea is that the models are the source of truth for the data shapes. But you can probably do it that way with pure SQLAlchemy. 🤓 |
This would be technically not supported by SQLModel, as the idea is that the models are the source of truth for the data shapes. But you can probably do it that way with pure SQLAlchemy. 🤓