Skip to content

Instantly share code, notes, and snippets.

@BetterProgramming
Created May 26, 2022 19:26
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BetterProgramming/83edee29166269f0e622f81ca85e6a1f to your computer and use it in GitHub Desktop.
Save BetterProgramming/83edee29166269f0e622f81ca85e6a1f to your computer and use it in GitHub Desktop.
#main.py
from fastapi import FastAPI,Body, Depends
import schemas
import models
from database import Base, engine, SessionLocal
from sqlalchemy.orm import Session
#This will create our database if it doesent already exists
Base.metadata.create_all(engine)
def get_session():
session = SessionLocal()
try:
yield session
finally:
session.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment