rajaramesh's picture
initial commit from machine
61f1726
raw
history blame contribute delete
579 Bytes
from sqlalchemy import create_engine, engine
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import sessionmaker
from pathlib import Path
full_path_dir = Path(__file__).resolve().parent
SQLALCHEMY_DATABASE_URL = f'sqlite:///{full_path_dir}/dbfiles/user.db'
engine = create_engine(SQLALCHEMY_DATABASE_URL, connect_args={'check_same_thread': False})
SessionLocal = sessionmaker(bind=engine, autocommit=False, autoflush=False)
Base = declarative_base()
def get_db():
db = SessionLocal()
try:
yield db
finally:
db.close()