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

Function create_hero

docs_src/tutorial/fastapi/update/tutorial002_py310.py:56–64  ·  view source on GitHub ↗
(hero: HeroCreate)

Source from the content-addressed store, hash-verified

54
55@app.post("/heroes/", response_model=HeroPublic)
56def create_hero(hero: HeroCreate):
57 hashed_password = hash_password(hero.password)
58 with Session(engine) as session:
59 extra_data = {"hashed_password": hashed_password}
60 db_hero = Hero.model_validate(hero, update=extra_data)
61 session.add(db_hero)
62 session.commit()
63 session.refresh(db_hero)
64 return db_hero
65
66
67@app.get("/heroes/", response_model=list[HeroPublic])

Callers

nothing calls this directly

Calls 3

SessionClass · 0.90
hash_passwordFunction · 0.85
model_validateMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…