MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / IteratorResult

Class IteratorResult

lib/sqlalchemy/engine/result.py:1812–1906  ·  view source on GitHub ↗

A :class:`_engine.Result` that gets data from a Python iterator of :class:`_engine.Row` objects or similar row-like data. .. versionadded:: 1.4

Source from the content-addressed store, hash-verified

1810
1811
1812class IteratorResult(Result[Unpack[_Ts]]):
1813 """A :class:`_engine.Result` that gets data from a Python iterator of
1814 :class:`_engine.Row` objects or similar row-like data.
1815
1816 .. versionadded:: 1.4
1817
1818 """
1819
1820 _hard_closed = False
1821 _soft_closed = False
1822
1823 def __init__(
1824 self,
1825 cursor_metadata: ResultMetaData,
1826 iterator: Iterator[_InterimSupportsScalarsRowType],
1827 raw: Optional[Result[Any]] = None,
1828 _source_supports_scalars: bool = False,
1829 context: Optional[Any] = None,
1830 ):
1831 self._metadata = cursor_metadata
1832 self.iterator = iterator
1833 self.raw = raw
1834 self._source_supports_scalars = _source_supports_scalars
1835 self.context = context
1836
1837 @property
1838 def closed(self) -> bool:
1839 """Return ``True`` if this :class:`_engine.IteratorResult` was
1840 **hard closed** by explicitly calling the :meth:`_engine.Result.close`
1841 method.
1842
1843 The attribute is **not** True if the :class:`_engine.Result` was only
1844 **soft closed**; a "soft close" is the style of close that takes place
1845 for example when the :class:`.CursorResult` is returned for a DML
1846 only statement without RETURNING, or when all result rows are fetched.
1847
1848 .. seealso::
1849
1850 :attr:`.CursorResult.returns_rows` - attribute specific to
1851 :class:`.CursorResult` which indicates if the result is one that
1852 may return zero or more rows
1853
1854 """
1855 return self._hard_closed
1856
1857 def _soft_close(self, hard: bool = False, **kw: Any) -> None:
1858 if hard:
1859 self._hard_closed = True
1860 if self.raw is not None:
1861 self.raw._soft_close(hard=hard, **kw)
1862 self.iterator = iter([])
1863 self._reset_memoizations()
1864 self._soft_closed = True
1865
1866 def _raise_hard_closed(self) -> NoReturn:
1867 raise exc.ResourceClosedError("This result object is closed.")
1868
1869 def _raw_row_iterator(self) -> Iterator[_RowData]:

Callers 3

__call__Method · 0.70
null_resultFunction · 0.70
null_dml_resultFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected