Chrome Extension

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: 'johndeo@domain.com',
    UserModel.city: 'New York'
})

session.commit()
Best JSON Validator, JSON Tree Viewer, JSON Beautifier at same place. Check how cool is the tool

In the code snippet, we are updating the User's email, username, the city which has id 20.

Was this helpful?
0 Comments