Put in order · Python course · Module 6: Async and FastAPI

Async endpoint with database

Arrange an endpoint that fetches data from the database asynchronously:

Items to put in order

  • result = await db.execute(select(Species))
  • async def get_species(db: AsyncSession = Depends(get_db)):
  • return result.scalars().all()
  • @app.get('/species')

You can check the correct answer by solving this task in the CodeWorlds game.