GitHub

Procedure

API reference for Procedure.

A stored procedure whose rows are As.

Attributes

AttributeTypeDescription
namestr
paramstuple[Parameter[Any], ...] = ()
output_paramstuple[Parameter[Any], ...] = ()

Functions

__init__

__init__(name, params=(), output_params=()) -> None
ParameterTypeDescription
namestr
paramstuple[Parameter[Any], ...] = ()
output_paramstuple[Parameter[Any], ...] = ()

param

param(parameter) -> Procedure[A_co]

With the input parameter.

ParameterTypeDescription
parameterParameter[Any]

Returns Procedure[A_co]

def param(self, parameter: Parameter[Any]) -> Procedure[A_co]:
    """With the input ``parameter``."""
    return Procedure(self.name, _with(self.params, parameter), self.output_params)

output_param

output_param(parameter) -> Procedure[A_co]

With the output parameter.

ParameterTypeDescription
parameterParameter[Any]

Returns Procedure[A_co]

def output_param(self, parameter: Parameter[Any]) -> Procedure[A_co]:
    """With the output ``parameter``."""
    return Procedure(self.name, self.params, _with(self.output_params, parameter))

with_rows

with_rows[B](row) -> Procedure[B]

Its rows typed as row (Effect's withRows<A>()).

ParameterTypeDescription
rowtype[B]

Returns Procedure[B]

def with_rows[B](self, row: type[B]) -> Procedure[B]:
    """Its rows typed as ``row`` (Effect's ``withRows<A>()``)."""
    return Procedure(self.name, self.params, self.output_params)

compile

compile(*values) -> ProcedureWithValues[A_co]

This procedure with a value for each input; ValueError when one is missing, repeated or not an input of it.

ParameterTypeDescription
valuesBound[Any] = ()

Returns ProcedureWithValues[A_co]

def compile(self, *values: Bound[Any]) -> ProcedureWithValues[A_co]:
    """This procedure with a value for each input; ``ValueError`` when one
    is missing, repeated or not an input of it."""
    bound: dict[str, object] = {}
    inputs = {p.name: p for p in self.params}
    for value in values:
        name = value.parameter.name
        if inputs.get(name) != value.parameter:
            raise ValueError(f"{name!r} is not an input of procedure {self.name!r}")
        if name in bound:
            raise ValueError(f"{name!r} is bound twice")
        bound[name] = value.value
    missing = [name for name in inputs if name not in bound]
    if missing:
        raise ValueError(f"procedure {self.name!r} needs values for {missing}")
    return ProcedureWithValues(self, bound)