[New Feature] Rest API implementation to showcase the OpenDBM features

This commit is contained in:
Rudy Haryanto
2022-10-04 03:07:29 +07:00
parent a574bc6870
commit 92e08860a8
41 changed files with 2576 additions and 0 deletions

View File

View File

@@ -0,0 +1,29 @@
from sqlalchemy import create_engine
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import sessionmaker
SQLALCHEMY_DATABASE_URL = "sqlite:///./app.db"
engine = create_engine(
SQLALCHEMY_DATABASE_URL,
connect_args={"check_same_thread": False},
)
SessionLocal = sessionmaker(
autocommit=False,
autoflush=False,
bind=engine,
)
Base = declarative_base()
def get_db():
db = SessionLocal()
try:
yield db
finally:
db.close()
def create_tables():
Base.metadata.create_all(bind=engine)

18
rest_api/app/config/db.py Normal file
View File

@@ -0,0 +1,18 @@
def get_db():
fake_users_db = {
"aicure": {
"username": "aicure",
"full_name": "AiCure OpenDBM",
"email": "opendbm@aicure.com",
"hashed_password": "$2b$12$k4R5SPuHkjFKBsQV5gAHl.e/BlxrX2z1H3vxiB9uGtaDZLFXjggCm",
"disabled": False,
},
"alice": {
"username": "alice",
"full_name": "Alice Wonderson",
"email": "alice@aicure.com",
"hashed_password": "fakehashedsecret2",
"disabled": True,
},
}
return fake_users_db