Skip to content

Instantly share code, notes, and snippets.

@DougAF
Created May 7, 2020 20:58
Show Gist options
  • Save DougAF/3c7bf2ca11788b11a317b4028dc4a2a6 to your computer and use it in GitHub Desktop.
Save DougAF/3c7bf2ca11788b11a317b4028dc4a2a6 to your computer and use it in GitHub Desktop.
FastAPI database file
import os
from sqlalchemy import create_engine
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import sessionmaker
SQLALCHEMY_DATABASE_URL = os.getenv("DB_CONN")
engine = create_engine(SQLALCHEMY_DATABASE_URL)
SessionLocal = sessionmaker(autocommit=False, autoflush=False, bind=engine)
Base = declarative_base()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment