from sqlmodel import create_engine, SQLModel, Session


sqlite_file_name = "database.db"
sqlite_url = f"sqlite:///{sqlite_file_name}"

connect_args = {"check_same_thread": False}
engine = create_engine(sqlite_url, echo=True, connect_args=connect_args)


def init_db():
    SQLModel.metadata.create_all(engine)


def get_session():
    with Session(engine) as session:
        yield session
sqlmodel.Session sqlmodel.SQLModel.metadata.create_all sqlmodel.create_engine
[((188, 251), 'sqlmodel.create_engine', 'create_engine', (['sqlite_url'], {'echo': '(True)', 'connect_args': 'connect_args'}), '(sqlite_url, echo=True, connect_args=connect_args)\n', (201, 251), False, 'from sqlmodel import create_engine, SQLModel, Session\n'), ((273, 309), 'sqlmodel.SQLModel.metadata.create_all', 'SQLModel.metadata.create_all', (['engine'], {}), '(engine)\n', (301, 309), False, 'from sqlmodel import create_engine, SQLModel, Session\n'), ((340, 355), 'sqlmodel.Session', 'Session', (['engine'], {}), '(engine)\n', (347, 355), False, 'from sqlmodel import create_engine, SQLModel, Session\n')]