Cannot generate two pydantic models from the same SQLAlchemy model #88
-
For the create method of SQL model I need to exclude the id of a model, I'd like to call the PyUser = sqlalchemy_to_pydantic(User)
PyUserCreate = sqlalchemy_to_pydantic(User, exclude=['id']) Now the server and every thing starts just fine but when I try to fetch the openapi.json, I get a keyerror because the first model is not in the model map. I think line 36 in main.py is at fault pydantic_model = create_model(
db_model.__name__, __config__=config, **fields # type: ignore
) The I suggest to add an optional parameter |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Thanks for the patience with my reply! 😅 I deprecated this library a while ago in favor of SQLModel which would solve all the same use cases in a much better way, and I'm directing all the effort in that direction. SQLModel uses Pydantic models to define both data and table (SQL) models, so it's easier to do all these things, including that, it would be much, much simpler to do. 🚀 |
Beta Was this translation helpful? Give feedback.
Thanks for the patience with my reply! 😅
I deprecated this library a while ago in favor of SQLModel which would solve all the same use cases in a much better way, and I'm directing all the effort in that direction.
SQLModel uses Pydantic models to define both data and table (SQL) models, so it's easier to do all these things, including that, it would be much, much simpler to do. 🚀