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()
Code faster with devsheet chrome extension and increase productivity as a programmer
search code from your favorite search engine instantly.
Install Now

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

Was this helpful?
0 Comments
Open Code Manager We are hiring