Skip to content

ORM

Bases: Base

Base class for Jetio SQLAlchemy models.

Inherit from JetioModel to get: - a default integer primary key id - automatic table naming (if __tablename__ is not provided) - automatic generation of Pydantic schemas: __pydantic_read_model__ and __pydantic_create_model__ - inclusion in Jetio's model registry for OpenAPI docs

Example
class User(JetioModel):
    username: Mapped[str] = mapped_column(unique=True)
    email: Mapped[str]
Customizing schema output
class User(JetioModel):
    class API:
        exclude_from_read = ["hashed_password"]
Notes

Relationship collections (e.g. List[Post]) are excluded from read schemas by default to avoid heavy recursion and circular schemas.

to_dict()

Serialize this model instance using its auto-generated read schema.

Returns:

Name Type Description
dict

JSON-compatible representation of the ORM object.

Declare a SQLAlchemy relationship with Jetio's public API surface.

This is a thin wrapper around :func:sqlalchemy.orm.relationship so Jetio can expose a consistent import path (jetio.orm.relationship) for applications.

Returns:

Type Description
Relationship

sqlalchemy.orm.Relationship: SQLAlchemy relationship descriptor.