add get_db
method
This commit is contained in:
parent
79ec14516a
commit
fdea61b784
@ -1,6 +1,6 @@
|
||||
from fastapi import FastAPI
|
||||
import models
|
||||
from database import engine
|
||||
from database import engine, SessionLocal
|
||||
from pydantic import BaseModel
|
||||
|
||||
app = FastAPI()
|
||||
@ -8,6 +8,14 @@ app = FastAPI()
|
||||
models.Base.metadata.create_all(bind=engine)
|
||||
|
||||
|
||||
def get_db():
|
||||
db = SessionLocal()
|
||||
try:
|
||||
yield db
|
||||
finally:
|
||||
db.close()
|
||||
|
||||
|
||||
class Post:
|
||||
"""Post is a single forum post or reply"""
|
||||
id: int
|
||||
|
Loading…
Reference in New Issue
Block a user