SQL API
SQLEntity
Bases: SQLModel, Schema, HasOrm[Mapped[Any]], BaseSQLEntity[IDT], Generic[IDT, SourceT]
SQL entity with an optional signpost type checked on declaration.
__sql_source__
classmethod
Expose the source type for inference without constructing a source.
SQLEntityStream
Bases: SimpleAsyncEntityStream[E], AsyncEntityStreamable[E], SQLDataBackend
Entity stream backed by a SQLAlchemy Select.
Operations that SQL can express are pushed down into the statement (take → LIMIT, drop → OFFSET, sort by field → ORDER BY, distinct, count, first, column projection via to_values). Everything else (Python predicates/mappers) falls back to the in-memory stream over a server-side cursor — rows are never fully buffered.
__init__
__init__(
stmt: Select[tuple[E]] | BaseQuery[E, Select[tuple[E]]],
signpost: SQLSignpost
| Signpostable[AbstractAsyncContextManager[AsyncSession]],
) -> None
join
join[F: Entitieable, Key: Hashable, LeftOrm, RightOrm](
other: AsyncEntityStreamable[F],
*,
on: tuple[FieldRef[E, Key, LeftOrm], FieldRef[F, Key, RightOrm]],
) -> JoinedStream[E, F]
SQLQuery
Bases: BaseQuery[E, Select[tuple[E]]], Generic[E, SourceT]
Infer the entity's source; source= additionally pins its instance.
__init__
__init__(
entity: SQLEntityClassable[E, SourceT],
statement: Select[tuple[E]] | None = None,
limit_value: int | UndefinedType | None = Undefined,
offset_value: Annotated[int, Ge(0)] = 0,
conditions: tuple[Expression[E], ...] = (),
orderings: tuple[tuple[str, bool], ...] = (),
source: SourceT | None = None,
) -> None
SQLValueStream
Bases: SimpleAsyncValueStream[T], AsyncValueStreamable[T], SQLDataBackend
Single-column stream backed by a SQLAlchemy Select.
Pushes down take/drop/distinct/sort and the aggregate terminals (count, sum, min, max) into SQL; Python callables fall back to the in-memory stream over a server-side cursor.