Replies: 1 comment
-
so please say me i am using sqlmodel, i have not idea of sqlalchemy codes 😅 when i search a row instance and want to change the data, should i need to use session.add() or not . |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
First Check
Commit to Help
Example Code
Description
The documentation contains the following statement:
But the sqlalchemy documentation says the following:
Thus, it turns out that re-adding the updated instance to the session is not required.
Just in case, I copied the code from the documentation and checked the behavior in the in memory database, the rows are updated regardless of whether add is called after changing the attributes.
Operating System
Windows
Operating System Details
Windows 11 23H2 (AMD64) build 22631.3296
SQLModel Version
0.0.16
Python Version
Python 3.12.0
Additional Context
SQLModel documentation link: https://sqlmodel.tiangolo.com/tutorial/update/
SQLAlchemy documentation link: https://docs.sqlalchemy.org/en/20/tutorial/orm_data_manipulation.html#updating-orm-objects-using-the-unit-of-work-pattern
Beta Was this translation helpful? Give feedback.
All reactions