pre-commit-ci-lite[bot]
1 month ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with
7 additions and
1 deletions
-
docs_src/sql_databases/tutorial001_an_py310.py
-
docs_src/sql_databases/tutorial002_an_py310.py
|
|
|
@ -1,5 +1,6 @@ |
|
|
|
from contextlib import asynccontextmanager |
|
|
|
from typing import Annotated |
|
|
|
|
|
|
|
from fastapi import Depends, FastAPI, HTTPException, Query |
|
|
|
from sqlmodel import Field, Session, SQLModel, create_engine, select |
|
|
|
|
|
|
|
@ -29,11 +30,13 @@ def get_session(): |
|
|
|
|
|
|
|
SessionDep = Annotated[Session, Depends(get_session)] |
|
|
|
|
|
|
|
|
|
|
|
@asynccontextmanager |
|
|
|
async def lifespan(app: FastAPI): |
|
|
|
create_db_and_tables() |
|
|
|
yield |
|
|
|
|
|
|
|
|
|
|
|
app = FastAPI(lifespan=lifespan) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -1,5 +1,6 @@ |
|
|
|
from contextlib import asynccontextmanager |
|
|
|
from typing import Annotated |
|
|
|
|
|
|
|
from fastapi import Depends, FastAPI, HTTPException, Query |
|
|
|
from sqlmodel import Field, Session, SQLModel, create_engine, select |
|
|
|
|
|
|
|
@ -45,11 +46,13 @@ def get_session(): |
|
|
|
|
|
|
|
|
|
|
|
SessionDep = Annotated[Session, Depends(get_session)] |
|
|
|
|
|
|
|
|
|
|
|
@asynccontextmanager |
|
|
|
async def lifespan(app: FastAPI): |
|
|
|
create_db_and_tables() |
|
|
|
yield |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app = FastAPI(lifespan=lifespan) |
|
|
|
|
|
|
|
|