python
Update column values query in SQLAlchemy
You can update column values of a row in SQLAlchemy by using the .update() method and assigning new values to its model properties.
session.query(
UserModel
).filter(
UserModel.id == 20
).update({
UserModel.username: 'john_deo',
UserModel.email: '[email protected]',
UserModel.city: 'New York'
})
session.commit()
In the code snippet, we are updating the User's email, username, the city which has id 20.
Was this helpful?
Similar Posts
- Get highest id or value record from a column SqlAlchemy Query
- Update dictionary values in python
- Column and data types in Sqlalchemy
- Column name as alias name SQLAlchemy
- Add column to existing table with default value SQLAlchemy
- Count Rows group by column name SqlAlchemy
- Filter based on NULL Values in SQLAlchemy