Enable attribute-based validation on the schema (from_attributes=True in Pydantic v2, formerly orm_mode in v1) so a Pydantic model can be built from an ORM object.
from pydantic import BaseModel, ConfigDict
class ItemOut(BaseModel):
model_config = ConfigDict(from_attributes=True)
id: int
name: str
price: float