from sqlmodel import create_engine, Session
from sqlmodel.main import SQLModel

from core.config import settings

engine = create_engine(settings.SQLALCHEMY_DATABASE_URI, pool_pre_ping=True)


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


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

sqlmodel.main.SQLModel.metadata.create_all sqlmodel.Session sqlmodel.create_engine
[((123, 190), 'sqlmodel.create_engine', 'create_engine', (['settings.SQLALCHEMY_DATABASE_URI'], {'pool_pre_ping': '(True)'}), '(settings.SQLALCHEMY_DATABASE_URI, pool_pre_ping=True)\n', (136, 190), False, 'from sqlmodel import create_engine, Session\n'), ((212, 248), 'sqlmodel.main.SQLModel.metadata.create_all', 'SQLModel.metadata.create_all', (['engine'], {}), '(engine)\n', (240, 248), False, 'from sqlmodel.main import SQLModel\n'), ((279, 294), 'sqlmodel.Session', 'Session', (['engine'], {}), '(engine)\n', (286, 294), False, 'from sqlmodel import create_engine, Session\n')]