Results of 1 - 1 of about 1 for SessionDep (0.006 sec.)
- SQL (Relational) Databases 9414
- SQL (Relational) Databases Warning The current page still doesn't have a translation for this language. But you can help translating it: Contributing . FastAPI doesn't require you to use a SQL (relational) database. But you can use any data
...les (): SQLModel . metadata . create_all ( engine ) def get_session (): with Session ( engine ) as session : yield session SessionDep = Annotated [ Session , Depends ( get_session )] app = FastAPI () @app . on_event ( "startup" ) def on_startup (): 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/" ) de...f read_heroes ( session : SessionDep , offset : int = 0 , limit : Annotated [ int , Query ( le = 100 )] = 100 , ) -> list [ Hero ]: heroes = session . exec ( s... - https://man.mtool.work/fastapi/0.115/tutorial/sql-databases/
PREV
1
NEXT