import os
from sqlmodel import create_engine, Session

from eveal import models_sde

sqlite_file_name = os.getenv("SQLITE_DB_PATH", "eveal.db")
engine = create_engine(f"sqlite:///{sqlite_file_name}", echo=True, future=True, connect_args={"check_same_thread": False})

def get_session():
    db = Session(engine)
    try:
        yield db
    finally:
        db.close()
