MCPcopy Index your code
hub / github.com/fastapi/sqlmodel / update_team

Function update_team

docs_src/tutorial/fastapi/teams/tutorial001_py310.py:164–178  ·  view source on GitHub ↗
(
    *,
    session: Session = Depends(get_session),
    team_id: int,
    team: TeamUpdate,
)

Source from the content-addressed store, hash-verified

162
163@app.patch("/teams/{team_id}", response_model=TeamPublic)
164def update_team(
165 *,
166 session: Session = Depends(get_session),
167 team_id: int,
168 team: TeamUpdate,
169):
170 db_team = session.get(Team, team_id)
171 if not db_team:
172 raise HTTPException(status_code=404, detail="Team not found")
173 team_data = team.model_dump(exclude_unset=True)
174 db_team.sqlmodel_update(team_data)
175 session.add(db_team)
176 session.commit()
177 session.refresh(db_team)
178 return db_team
179
180
181@app.delete("/teams/{team_id}")

Callers

nothing calls this directly

Calls 2

model_dumpMethod · 0.80
sqlmodel_updateMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…