awesome-fastapi-projects/populate/database.py
Marcelo Trylesinski 3dd21d4d04 Refactor project
2021-11-16 17:44:33 +01:00

9 lines
311 B
Python

import os
from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker
db_dir = os.path.abspath(os.getcwd() + "/data/db.sqlite")
engine = create_engine("sqlite:///" + db_dir, connect_args={"check_same_thread": True})
SessionLocal = sessionmaker(autocommit=False, autoflush=False, bind=engine)