from sqlmodel import Session, select
from .models import Person, engine

def create_person(nome: str, idade:int):
    person = Person(nome=nome, idade=idade)
    with Session(engine) as session:
        session.add(person)
        session.commit()
        session.refresh(person)

    return person


def all_person():
        query = select(Person)
        with Session(engine) as session:
            result = session.execute(query).scalars().all()
        return result
sqlmodel.Session sqlmodel.select
[((335, 349), 'sqlmodel.select', 'select', (['Person'], {}), '(Person)\n', (341, 349), False, 'from sqlmodel import Session, select\n'), ((167, 182), 'sqlmodel.Session', 'Session', (['engine'], {}), '(engine)\n', (174, 182), False, 'from sqlmodel import Session, select\n'), ((363, 378), 'sqlmodel.Session', 'Session', (['engine'], {}), '(engine)\n', (370, 378), False, 'from sqlmodel import Session, select\n')]