Sometimes you will need to update a certain column value of an entry in your database. This is rather easy in the context of SQLAlchemy ORM and is done in the same way you would change Python object’s attribute.
The commands below change the email of a reader with
id=3 and commit the changes to the database:
reader = Reader.query.get(3) reader.email = “[email protected]” db.session.commit()
If you want to undo the update, you can use
instead of committing.
get method, fetch a book entry with
id = 19 and assign it to the variable called
month attribute of
Commit the change.