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

Function create_hero

docs_src/tutorial/fastapi/read_one/tutorial001_py310.py:43–49  ·  view source on GitHub ↗
(hero: HeroCreate)

Source from the content-addressed store, hash-verified

41
42@app.post("/heroes/", response_model=HeroPublic)
43def create_hero(hero: HeroCreate):
44 with Session(engine) as session:
45 db_hero = Hero.model_validate(hero)
46 session.add(db_hero)
47 session.commit()
48 session.refresh(db_hero)
49 return db_hero
50
51
52@app.get("/heroes/", response_model=list[HeroPublic])

Callers

nothing calls this directly

Calls 2

SessionClass · 0.90
model_validateMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…