Moving to FastAPI

Config is not properly working with .env file as of now
Cost Centre is mostly working, going to work on Accounts now
This commit is contained in:
tanshu committed 2020-05-08 10:22:25 +05:30
1 parent 72044476a8
commit fe74ef44bf
89 files changed
+1516 -2421

No files matched your search

+25
View File
@@ -0,0 +1,25 @@
from sqlalchemy.orm import Session
from app import crud, schemas
from brewman.core.config import settings
from brewman.db import base # noqa: F401
# make sure all SQL Alchemy models are imported (app.db.base) before initializing DB
# otherwise, SQL Alchemy might fail to initialize relationships properly
# for more details: https://github.com/tiangolo/full-stack-fastapi-postgresql/issues/28
def init_db(db: Session) -> None:
# Tables should be created with Alembic migrations
# But if you don't want to use migrations, create
# the tables un-commenting the next line
# Base.metadata.create_all(bind=engine)
user = crud.user.get_by_email(db, email=settings.FIRST_SUPERUSER)
if not user:
user_in = schemas.UserCreate(
email=settings.FIRST_SUPERUSER,
password=settings.FIRST_SUPERUSER_PASSWORD,
is_superuser=True,
)
user = crud.user.create(db, obj_in=user_in) # noqa: F841