0PricingLogin
Flask Academy · Lesson

Update Existing Records Safely

Mutate fields and flush changes correctly.

The U in CRUD

Updating means changing an existing row, not making a new one. The trick is to load the record first, then edit it. ✏️

Find Before You Change

Always fetch the target row by its id before touching it. get_or_404() loads it or stops with a clean 404.

user = User.query.get_or_404(user_id)

All lessons in this course

  1. Create Records and Commit Sessions
  2. Read One and Read Many Endpoints
  3. Update Existing Records Safely
  4. Delete and Handle Missing Rows
← Back to Flask Academy