add get_db method

This commit is contained in:
agatha 2024-04-01 17:25:32 -04:00
parent 79ec14516a
commit fdea61b784

View File

@ -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