David Bejo 1 day ago
committed by GitHub
parent
commit
42593c51da
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 10
      docs_src/sql_databases/tutorial001.py
  2. 11
      docs_src/sql_databases/tutorial001_an.py
  3. 11
      docs_src/sql_databases/tutorial001_an_py310.py
  4. 11
      docs_src/sql_databases/tutorial001_an_py39.py
  5. 11
      docs_src/sql_databases/tutorial001_py310.py
  6. 10
      docs_src/sql_databases/tutorial001_py39.py
  7. 10
      docs_src/sql_databases/tutorial002.py
  8. 10
      docs_src/sql_databases/tutorial002_an.py
  9. 10
      docs_src/sql_databases/tutorial002_an_py310.py
  10. 10
      docs_src/sql_databases/tutorial002_an_py39.py
  11. 11
      docs_src/sql_databases/tutorial002_py310.py
  12. 10
      docs_src/sql_databases/tutorial002_py39.py

10
docs_src/sql_databases/tutorial001.py

@ -1,3 +1,4 @@
from contextlib import asynccontextmanager
from typing import List, Union
from fastapi import Depends, FastAPI, HTTPException, Query
@ -27,12 +28,13 @@ def get_session():
yield session
app = FastAPI()
@asynccontextmanager
async def lifespan(app: FastAPI):
create_db_and_tables()
yield
@app.on_event("startup")
def on_startup():
create_db_and_tables()
app = FastAPI(lifespan=lifespan)
@app.post("/heroes/")

11
docs_src/sql_databases/tutorial001_an.py

@ -1,3 +1,4 @@
from contextlib import asynccontextmanager
from typing import List, Union
from fastapi import Depends, FastAPI, HTTPException, Query
@ -30,12 +31,14 @@ def get_session():
SessionDep = Annotated[Session, Depends(get_session)]
app = FastAPI()
@app.on_event("startup")
def on_startup():
@asynccontextmanager
async def lifespan(app: FastAPI):
create_db_and_tables()
yield
app = FastAPI(lifespan=lifespan)
@app.post("/heroes/")

11
docs_src/sql_databases/tutorial001_an_py310.py

@ -1,3 +1,4 @@
from contextlib import asynccontextmanager
from typing import Annotated
from fastapi import Depends, FastAPI, HTTPException, Query
@ -29,12 +30,14 @@ def get_session():
SessionDep = Annotated[Session, Depends(get_session)]
app = FastAPI()
@app.on_event("startup")
def on_startup():
@asynccontextmanager
async def lifespan(app: FastAPI):
create_db_and_tables()
yield
app = FastAPI(lifespan=lifespan)
@app.post("/heroes/")

11
docs_src/sql_databases/tutorial001_an_py39.py

@ -1,3 +1,4 @@
from contextlib import asynccontextmanager
from typing import Annotated, Union
from fastapi import Depends, FastAPI, HTTPException, Query
@ -29,12 +30,14 @@ def get_session():
SessionDep = Annotated[Session, Depends(get_session)]
app = FastAPI()
@app.on_event("startup")
def on_startup():
@asynccontextmanager
async def lifespan(app: FastAPI):
create_db_and_tables()
yield
app = FastAPI(lifespan=lifespan)
@app.post("/heroes/")

11
docs_src/sql_databases/tutorial001_py310.py

@ -1,3 +1,5 @@
from contextlib import asynccontextmanager
from fastapi import Depends, FastAPI, HTTPException, Query
from sqlmodel import Field, Session, SQLModel, create_engine, select
@ -25,12 +27,13 @@ def get_session():
yield session
app = FastAPI()
@asynccontextmanager
async def lifespan(app: FastAPI):
create_db_and_tables()
yield
@app.on_event("startup")
def on_startup():
create_db_and_tables()
app = FastAPI(lifespan=lifespan)
@app.post("/heroes/")

10
docs_src/sql_databases/tutorial001_py39.py

@ -1,3 +1,4 @@
from contextlib import asynccontextmanager
from typing import Union
from fastapi import Depends, FastAPI, HTTPException, Query
@ -27,12 +28,13 @@ def get_session():
yield session
app = FastAPI()
@asynccontextmanager
async def lifespan(app: FastAPI):
create_db_and_tables()
yield
@app.on_event("startup")
def on_startup():
create_db_and_tables()
app = FastAPI(lifespan=lifespan)
@app.post("/heroes/")

10
docs_src/sql_databases/tutorial002.py

@ -1,3 +1,4 @@
from contextlib import asynccontextmanager
from typing import List, Union
from fastapi import Depends, FastAPI, HTTPException, Query
@ -44,12 +45,13 @@ def get_session():
yield session
app = FastAPI()
@asynccontextmanager
async def lifespan(app: FastAPI):
create_db_and_tables()
yield
@app.on_event("startup")
def on_startup():
create_db_and_tables()
app = FastAPI(lifespan=lifespan)
@app.post("/heroes/", response_model=HeroPublic)

10
docs_src/sql_databases/tutorial002_an.py

@ -1,3 +1,4 @@
from contextlib import asynccontextmanager
from typing import List, Union
from fastapi import Depends, FastAPI, HTTPException, Query
@ -46,12 +47,15 @@ def get_session():
SessionDep = Annotated[Session, Depends(get_session)]
app = FastAPI()
@app.on_event("startup")
def on_startup():
@asynccontextmanager
async def lifespan(app: FastAPI):
create_db_and_tables()
yield
app = FastAPI(lifespan=lifespan)
@app.post("/heroes/", response_model=HeroPublic)

10
docs_src/sql_databases/tutorial002_an_py310.py

@ -1,3 +1,4 @@
from contextlib import asynccontextmanager
from typing import Annotated
from fastapi import Depends, FastAPI, HTTPException, Query
@ -45,12 +46,15 @@ def get_session():
SessionDep = Annotated[Session, Depends(get_session)]
app = FastAPI()
@app.on_event("startup")
def on_startup():
@asynccontextmanager
async def lifespan(app: FastAPI):
create_db_and_tables()
yield
app = FastAPI(lifespan=lifespan)
@app.post("/heroes/", response_model=HeroPublic)

10
docs_src/sql_databases/tutorial002_an_py39.py

@ -1,3 +1,4 @@
from contextlib import asynccontextmanager
from typing import Annotated, Union
from fastapi import Depends, FastAPI, HTTPException, Query
@ -45,12 +46,15 @@ def get_session():
SessionDep = Annotated[Session, Depends(get_session)]
app = FastAPI()
@app.on_event("startup")
def on_startup():
@asynccontextmanager
async def lifespan(app: FastAPI):
create_db_and_tables()
yield
app = FastAPI(lifespan=lifespan)
@app.post("/heroes/", response_model=HeroPublic)

11
docs_src/sql_databases/tutorial002_py310.py

@ -1,3 +1,5 @@
from contextlib import asynccontextmanager
from fastapi import Depends, FastAPI, HTTPException, Query
from sqlmodel import Field, Session, SQLModel, create_engine, select
@ -42,12 +44,13 @@ def get_session():
yield session
app = FastAPI()
@asynccontextmanager
async def lifespan(app: FastAPI):
create_db_and_tables()
yield
@app.on_event("startup")
def on_startup():
create_db_and_tables()
app = FastAPI(lifespan=lifespan)
@app.post("/heroes/", response_model=HeroPublic)

10
docs_src/sql_databases/tutorial002_py39.py

@ -1,3 +1,4 @@
from contextlib import asynccontextmanager
from typing import Union
from fastapi import Depends, FastAPI, HTTPException, Query
@ -44,12 +45,13 @@ def get_session():
yield session
app = FastAPI()
@asynccontextmanager
async def lifespan(app: FastAPI):
create_db_and_tables()
yield
@app.on_event("startup")
def on_startup():
create_db_and_tables()
app = FastAPI(lifespan=lifespan)
@app.post("/heroes/", response_model=HeroPublic)

Loading…
Cancel
Save