from sqlmodel import SQLModel, create_engine, Session

from victor_api.config import settings

engine = create_engine(
    url=settings.db.url,
    echo=settings.db.echo,
    connect_args=settings.db.connect_args
)


def get_session():
    with Session(engine) as session:
        yield session


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

sqlmodel.Session sqlmodel.SQLModel.metadata.create_all sqlmodel.create_engine
[((104, 205), 'sqlmodel.create_engine', 'create_engine', ([], {'url': 'settings.db.url', 'echo': 'settings.db.echo', 'connect_args': 'settings.db.connect_args'}), '(url=settings.db.url, echo=settings.db.echo, connect_args=\n    settings.db.connect_args)\n', (117, 205), False, 'from sqlmodel import SQLModel, create_engine, Session\n'), ((316, 352), 'sqlmodel.SQLModel.metadata.create_all', 'SQLModel.metadata.create_all', (['engine'], {}), '(engine)\n', (344, 352), False, 'from sqlmodel import SQLModel, create_engine, Session\n'), ((245, 260), 'sqlmodel.Session', 'Session', (['engine'], {}), '(engine)\n', (252, 260), False, 'from sqlmodel import SQLModel, create_engine, Session\n')]