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

Function create_hero

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

Source from the content-addressed store, hash-verified

47
48@app.post("/heroes/", response_model=HeroPublic)
49def create_hero(hero: HeroCreate):
50 with Session(engine) as session:
51 db_hero = Hero.model_validate(hero)
52 session.add(db_hero)
53 session.commit()
54 session.refresh(db_hero)
55 return db_hero
56
57
58@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…