MCPcopy Create free account
hub / github.com/MagicStack/asyncpg / CursorFactory

Class CursorFactory

asyncpg/cursor.py:14–80  ·  view source on GitHub ↗

A cursor interface for the results of a query. A cursor interface can be used to initiate efficient traversal of the results of a large query.

Source from the content-addressed store, hash-verified

12
13
14class CursorFactory(connresource.ConnectionResource):
15 """A cursor interface for the results of a query.
16
17 A cursor interface can be used to initiate efficient traversal of the
18 results of a large query.
19 """
20
21 __slots__ = (
22 '_state',
23 '_args',
24 '_prefetch',
25 '_query',
26 '_timeout',
27 '_record_class',
28 )
29
30 def __init__(
31 self,
32 connection,
33 query,
34 state,
35 args,
36 prefetch,
37 timeout,
38 record_class
39 ):
40 super().__init__(connection)
41 self._args = args
42 self._prefetch = prefetch
43 self._query = query
44 self._timeout = timeout
45 self._state = state
46 self._record_class = record_class
47 if state is not None:
48 state.attach()
49
50 @connresource.guarded
51 def __aiter__(self):
52 prefetch = 50 if self._prefetch is None else self._prefetch
53 return CursorIterator(
54 self._connection,
55 self._query,
56 self._state,
57 self._args,
58 self._record_class,
59 prefetch,
60 self._timeout,
61 )
62
63 @connresource.guarded
64 def __await__(self):
65 if self._prefetch is not None:
66 raise exceptions.InterfaceError(
67 'prefetch argument can only be specified for iterable cursor')
68 cursor = Cursor(
69 self._connection,
70 self._query,
71 self._state,

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…