-
-
Notifications
You must be signed in to change notification settings - Fork 671
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Flexibly Create Nested Database Entries from Incoming Pydantic/SQLModels #6
Comments
Hello @hay-kot , i have tried your solution on nested models, and it works just fine, I will try with more nested pedantic models and see if it works, yet I would greatly appreciate if you could provide some explanation(documentation) of what you did because although I read it many times, I am still afraid to use it for production. |
SQLModel is fantastic as it cuts so much time out managing pydantic schemas and sqlalchemy models. I too would like to know how to create database entries with incoming nested SQLModels. Does anyone know how to do this yet? |
It's even worse than use separate pydantic and sqlalchemy models because the nested list on the payload received from client are always empty. So it's not even possible to create each element separarely |
Agree with @hay-kot : it would be great to have the ability to instantiate nested objects from a nested SQLModel instance. |
This would such an amazing feature. Any update on this? |
fix: nullable property of fields
Any update on this ? |
This is a major feature that is missing from sqlmodel that is preventing myself from migrating a larger project from marshmallow. There is a lot of boilerplate code that needs to be added to handle nested objects |
I would also love to see this addition to the awesome SQLModel library. |
Started working with this wonderful library and encountered the same problem. Any updates? |
+1 on this. First of all, this library looks amazing! Last year, I was using Sqlalchemy and Pydantic models separately, but this library would be such a quality of life improvement.. Unfortunately, the fact that this feature is missing is a deal breaker, so i cannot start using it. Last year, I also built a custom recursive solution to do this in Sqlalchemy+Pydantic, just like OP did. But, I don't think it would be easy/a good idea to port it to SqlModels... Any updates would be greatly appreciated! |
Any update on this? Would love to use |
There any temporary guidance from best practices to avoid this issue? |
any updates on it? this is something that will be amazing for SQLModel to have. |
Hi, is there any updates or fixes for this? |
Still facing these issues is there any updates about? |
I successfully solved all these problems in one line. Just by converting my pydantic class models to dictionary and storing the dictionary in the database through SQLModel"s, class table=True |
@UmarBelloKanwa Can you elaborate on this? |
Could you provide a short code sample for this? I'm not 100% sure what you mean. |
You have to convert your base model to Or look to this tutorial: |
First Check
Commit to Help
Example Code
Description
I would like to do what is described in FastAPI issue #2194
In the example above, I'd like to pass in the payload to a method and the following to occur.
Similarly, I'd like the same to happen on update. Effectively making writing to the SQL database akin to writing to MongoDB
I don't believe this is supported or haven't gotten it to work, but my main questions are.
Loving working with this so far, thanks for all your hard work!
Operating System
macOS
Operating System Details
No response
SQLModel Version
0.0.3
Python Version
3.9.6
Additional Context
I have accomplished this with SQLAlchemy in the past by using an
auto_init
decarator.Usage
The text was updated successfully, but these errors were encountered: