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

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

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.SQLModel.metadata.create_all sqlmodel.Field sqlmodel.create_engine sqlmodel.Session
[((99, 149), 'sqlmodel.create_engine', 'create_engine', ([], {'url': '"""sqlite:///users.db"""', 'echo': '(True)'}), "(url='sqlite:///users.db', echo=True)\n", (112, 149), False, 'from sqlmodel import SQLModel, Field, create_engine, Session\n'), ((208, 237), 'sqlmodel.Field', 'Field', (['None'], {'primary_key': '(True)'}), '(None, primary_key=True)\n', (213, 237), False, 'from sqlmodel import SQLModel, Field, create_engine, Session\n'), ((372, 408), 'sqlmodel.SQLModel.metadata.create_all', 'SQLModel.metadata.create_all', (['engine'], {}), '(engine)\n', (400, 408), False, 'from sqlmodel import SQLModel, Field, create_engine, Session\n'), ((302, 317), 'sqlmodel.Session', 'Session', (['engine'], {}), '(engine)\n', (309, 317), False, 'from sqlmodel import SQLModel, Field, create_engine, Session\n')]