Search Options

Results per page
Sort
Preferred Languages
Advance

Results 1 - 10 of 169 for Heroes (0.17 sec)

  1. docs_src/sql_databases/tutorial002_py310.py

        offset: int = 0,
        limit: int = Query(default=100, le=100),
    ):
        heroes = session.exec(select(Hero).offset(offset).limit(limit)).all()
        return heroes
    
    
    @app.get("/heroes/{hero_id}", response_model=HeroPublic)
    def read_hero(hero_id: int, session: Session = Depends(get_session)):
        hero = session.get(Hero, hero_id)
        if not hero:
            raise HTTPException(status_code=404, detail="Hero not found")
        return hero
    
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Wed Oct 09 19:44:42 UTC 2024
    - 2.5K bytes
    - Viewed (0)
  2. docs_src/sql_databases/tutorial001_an_py310.py

        create_db_and_tables()
    
    
    @app.post("/heroes/")
    def create_hero(hero: Hero, session: SessionDep) -> Hero:
        session.add(hero)
        session.commit()
        session.refresh(hero)
        return hero
    
    
    @app.get("/heroes/")
    def read_heroes(
        session: SessionDep,
        offset: int = 0,
        limit: Annotated[int, Query(le=100)] = 100,
    ) -> list[Hero]:
        heroes = session.exec(select(Hero).offset(offset).limit(limit)).all()
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Wed Oct 09 19:44:42 UTC 2024
    - 1.7K bytes
    - Viewed (0)
  3. docs_src/sql_databases/tutorial002_an.py

    ):
        heroes = session.exec(select(Hero).offset(offset).limit(limit)).all()
        return heroes
    
    
    @app.get("/heroes/{hero_id}", response_model=HeroPublic)
    def read_hero(hero_id: int, session: SessionDep):
        hero = session.get(Hero, hero_id)
        if not hero:
            raise HTTPException(status_code=404, detail="Hero not found")
        return hero
    
    
    @app.patch("/heroes/{hero_id}", response_model=HeroPublic)
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Wed Oct 09 19:44:42 UTC 2024
    - 2.6K bytes
    - Viewed (0)
  4. docs_src/sql_databases/tutorial002_py39.py

        offset: int = 0,
        limit: int = Query(default=100, le=100),
    ):
        heroes = session.exec(select(Hero).offset(offset).limit(limit)).all()
        return heroes
    
    
    @app.get("/heroes/{hero_id}", response_model=HeroPublic)
    def read_hero(hero_id: int, session: Session = Depends(get_session)):
        hero = session.get(Hero, hero_id)
        if not hero:
            raise HTTPException(status_code=404, detail="Hero not found")
        return hero
    
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Wed Oct 09 19:44:42 UTC 2024
    - 2.6K bytes
    - Viewed (0)
  5. docs_src/sql_databases/tutorial002_an_py39.py

    ):
        heroes = session.exec(select(Hero).offset(offset).limit(limit)).all()
        return heroes
    
    
    @app.get("/heroes/{hero_id}", response_model=HeroPublic)
    def read_hero(hero_id: int, session: SessionDep):
        hero = session.get(Hero, hero_id)
        if not hero:
            raise HTTPException(status_code=404, detail="Hero not found")
        return hero
    
    
    @app.patch("/heroes/{hero_id}", response_model=HeroPublic)
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Wed Oct 09 19:44:42 UTC 2024
    - 2.5K bytes
    - Viewed (0)
  6. docs_src/sql_databases/tutorial001_py39.py

    ) -> list[Hero]:
        heroes = session.exec(select(Hero).offset(offset).limit(limit)).all()
        return heroes
    
    
    @app.get("/heroes/{hero_id}")
    def read_hero(hero_id: int, session: Session = Depends(get_session)) -> Hero:
        hero = session.get(Hero, hero_id)
        if not hero:
            raise HTTPException(status_code=404, detail="Hero not found")
        return hero
    
    
    @app.delete("/heroes/{hero_id}")
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Wed Oct 09 19:44:42 UTC 2024
    - 1.8K bytes
    - Viewed (0)
  7. docs_src/sql_databases/tutorial001_an.py

        create_db_and_tables()
    
    
    @app.post("/heroes/")
    def create_hero(hero: Hero, session: SessionDep) -> Hero:
        session.add(hero)
        session.commit()
        session.refresh(hero)
        return hero
    
    
    @app.get("/heroes/")
    def read_heroes(
        session: SessionDep,
        offset: int = 0,
        limit: Annotated[int, Query(le=100)] = 100,
    ) -> List[Hero]:
        heroes = session.exec(select(Hero).offset(offset).limit(limit)).all()
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Wed Oct 09 19:44:42 UTC 2024
    - 1.8K bytes
    - Viewed (0)
  8. tests/test_tutorial/test_sql_databases/test_tutorial001.py

            response = client.get(f"/heroes/{hero_id}")
            assert response.status_code == 200, response.text
            assert response.json() == snapshot(
                {"name": "Dead Pond", "age": 30, "id": 999, "secret_name": "Dive Wilson"}
            )
    
            # Read all heroes
            # Create more heroes first
            response = client.post(
                "/heroes/",
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Wed Oct 09 19:44:42 UTC 2024
    - 14.8K bytes
    - Viewed (0)
  9. docs_src/sql_databases/tutorial001.py

    ) -> List[Hero]:
        heroes = session.exec(select(Hero).offset(offset).limit(limit)).all()
        return heroes
    
    
    @app.get("/heroes/{hero_id}")
    def read_hero(hero_id: int, session: Session = Depends(get_session)) -> Hero:
        hero = session.get(Hero, hero_id)
        if not hero:
            raise HTTPException(status_code=404, detail="Hero not found")
        return hero
    
    
    @app.delete("/heroes/{hero_id}")
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Wed Oct 09 19:44:42 UTC 2024
    - 1.8K bytes
    - Viewed (0)
  10. docs_src/sql_databases/tutorial001_py310.py

    ) -> list[Hero]:
        heroes = session.exec(select(Hero).offset(offset).limit(limit)).all()
        return heroes
    
    
    @app.get("/heroes/{hero_id}")
    def read_hero(hero_id: int, session: Session = Depends(get_session)) -> Hero:
        hero = session.get(Hero, hero_id)
        if not hero:
            raise HTTPException(status_code=404, detail="Hero not found")
        return hero
    
    
    @app.delete("/heroes/{hero_id}")
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Wed Oct 09 19:44:42 UTC 2024
    - 1.7K bytes
    - Viewed (0)
Back to top