MCPcopy Create free account
hub / github.com/sqlalchemy/sqlalchemy / AsyncResult

Class AsyncResult

lib/sqlalchemy/ext/asyncio/result.py:66–487  ·  view source on GitHub ↗

An asyncio wrapper around a :class:`_result.Result` object. The :class:`_asyncio.AsyncResult` only applies to statement executions that use a server-side cursor. It is returned only from the :meth:`_asyncio.AsyncConnection.stream` and :meth:`_asyncio.AsyncSession.stream` methods.

Source from the content-addressed store, hash-verified

64
65
66class AsyncResult(_WithKeys, AsyncCommon[Row[_TP]]):
67 """An asyncio wrapper around a :class:`_result.Result` object.
68
69 The :class:`_asyncio.AsyncResult` only applies to statement executions that
70 use a server-side cursor. It is returned only from the
71 :meth:`_asyncio.AsyncConnection.stream` and
72 :meth:`_asyncio.AsyncSession.stream` methods.
73
74 .. note:: As is the case with :class:`_engine.Result`, this object is
75 used for ORM results returned by :meth:`_asyncio.AsyncSession.execute`,
76 which can yield instances of ORM mapped objects either individually or
77 within tuple-like rows. Note that these result objects do not
78 deduplicate instances or rows automatically as is the case with the
79 legacy :class:`_orm.Query` object. For in-Python de-duplication of
80 instances or rows, use the :meth:`_asyncio.AsyncResult.unique` modifier
81 method.
82
83 .. versionadded:: 1.4
84
85 """
86
87 __slots__ = ()
88
89 _real_result: Result[_TP]
90
91 def __init__(self, real_result: Result[_TP]):
92 self._real_result = real_result
93
94 self._metadata = real_result._metadata
95 self._unique_filter_state = real_result._unique_filter_state
96 self._source_supports_scalars = real_result._source_supports_scalars
97 self._post_creational_filter = None
98
99 # BaseCursorResult pre-generates the "_row_getter". Use that
100 # if available rather than building a second one
101 if "_row_getter" in real_result.__dict__:
102 self._set_memoized_attribute(
103 "_row_getter", real_result.__dict__["_row_getter"]
104 )
105
106 @property
107 def t(self) -> AsyncTupleResult[_TP]:
108 """Apply a "typed tuple" typing filter to returned rows.
109
110 The :attr:`_asyncio.AsyncResult.t` attribute is a synonym for
111 calling the :meth:`_asyncio.AsyncResult.tuples` method.
112
113 .. versionadded:: 2.0
114
115 """
116 return self # type: ignore
117
118 def tuples(self) -> AsyncTupleResult[_TP]:
119 """Apply a "typed tuple" typing filter to returned rows.
120
121 This method returns the same :class:`_asyncio.AsyncResult` object
122 at runtime,
123 however annotates as returning a :class:`_asyncio.AsyncTupleResult`

Callers 2

streamMethod · 0.85
streamMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected