from typing import Optional
from sqlmodel import SQLModel, Field, create_engine, Session


engine = create_engine(url="sqlite:///users.db", echo=False)


class User(SQLModel, table=True):
    id: Optional[int] = Field(None, primary_key=True)
    username: str
    password: str

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


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


sqlmodel.Session sqlmodel.create_engine sqlmodel.Field sqlmodel.SQLModel.metadata.create_all
[((100, 151), 'sqlmodel.create_engine', 'create_engine', ([], {'url': '"""sqlite:///users.db"""', 'echo': '(False)'}), "(url='sqlite:///users.db', echo=False)\n", (113, 151), False, 'from sqlmodel import SQLModel, Field, create_engine, Session\n'), ((212, 241), 'sqlmodel.Field', 'Field', (['None'], {'primary_key': '(True)'}), '(None, primary_key=True)\n', (217, 241), False, 'from sqlmodel import SQLModel, Field, create_engine, Session\n'), ((378, 414), 'sqlmodel.SQLModel.metadata.create_all', 'SQLModel.metadata.create_all', (['engine'], {}), '(engine)\n', (406, 414), False, 'from sqlmodel import SQLModel, Field, create_engine, Session\n'), ((307, 322), 'sqlmodel.Session', 'Session', (['engine'], {}), '(engine)\n', (314, 322), False, 'from sqlmodel import SQLModel, Field, create_engine, Session\n')]