from sqlmodel import create_engine, SQLModel, Session

from .config import settings


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


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


def drop_db():
    SQLModel.metadata.drop_all(engine)


def get_session():
    with Session(engine) as session:
        yield session
sqlmodel.Session sqlmodel.create_engine sqlmodel.SQLModel.metadata.create_all sqlmodel.SQLModel.metadata.drop_all
[((95, 192), 'sqlmodel.create_engine', 'create_engine', (['settings.db.uri'], {'echo': 'settings.db.echo', 'connect_args': 'settings.db.connect_args'}), '(settings.db.uri, echo=settings.db.echo, connect_args=settings\n    .db.connect_args)\n', (108, 192), False, 'from sqlmodel import create_engine, SQLModel, Session\n'), ((223, 259), 'sqlmodel.SQLModel.metadata.create_all', 'SQLModel.metadata.create_all', (['engine'], {}), '(engine)\n', (251, 259), False, 'from sqlmodel import create_engine, SQLModel, Session\n'), ((281, 315), 'sqlmodel.SQLModel.metadata.drop_all', 'SQLModel.metadata.drop_all', (['engine'], {}), '(engine)\n', (307, 315), False, 'from sqlmodel import create_engine, SQLModel, Session\n'), ((346, 361), 'sqlmodel.Session', 'Session', (['engine'], {}), '(engine)\n', (353, 361), False, 'from sqlmodel import create_engine, SQLModel, Session\n')]