17 lines
585 B
Python
17 lines
585 B
Python
from pathlib import Path
|
|
|
|
from sqlalchemy import create_engine
|
|
from sqlalchemy.orm import sessionmaker
|
|
|
|
# Get the project root directory
|
|
PROJECT_ROOT = Path(__file__).parent.parent.parent.absolute()
|
|
|
|
# Create the directory for the SQLite database if it doesn't exist
|
|
DB_DIR = PROJECT_ROOT / "app" / "storage" / "db"
|
|
DB_DIR.mkdir(parents=True, exist_ok=True)
|
|
|
|
SQLALCHEMY_DATABASE_URL = f"sqlite:///{DB_DIR}/db.sqlite"
|
|
|
|
engine = create_engine(SQLALCHEMY_DATABASE_URL, connect_args={"check_same_thread": False})
|
|
SessionLocal = sessionmaker(autocommit=False, autoflush=False, bind=engine)
|