await self.close()
async def close(self) -> None:
+ """
+ Close the current cursor and free associated resources.
+ """
self._close()
@property
def row_factory(self) -> AsyncRowFactory[Row]:
+ """Writable attribute to control how result rows are formed."""
return self._row_factory
@row_factory.setter
prepare: Optional[bool] = None,
binary: Optional[bool] = None,
) -> _Self:
+ """
+ Execute a query or command to the database.
+ """
try:
async with self._conn.lock:
await self._conn.wait(
*,
returning: bool = False,
) -> None:
+ """
+ Execute the same command with a sequence of input data.
+ """
try:
if Pipeline.is_supported():
# If there is already a pipeline, ride it, in order to avoid
*,
binary: Optional[bool] = None,
) -> AsyncIterator[Row]:
+ """
+ Iterate row-by-row on a result from the database.
+ """
if self._pgconn.pipeline_status:
raise e.ProgrammingError("stream() cannot be used in pipeline mode")
pass
async def fetchone(self) -> Optional[Row]:
+ """
+ Return the next record from the current recordset.
+
+ Return `!None` the recordset is finished.
+
+ :rtype: Optional[Row], with Row defined by `row_factory`
+ """
await self._fetch_pipeline()
self._check_result_for_fetch()
record = self._tx.load_row(self._pos, self._make_row)
return record
async def fetchmany(self, size: int = 0) -> List[Row]:
+ """
+ Return the next `!size` records from the current recordset.
+
+ `!size` default to `!self.arraysize` if not specified.
+
+ :rtype: Sequence[Row], with Row defined by `row_factory`
+ """
await self._fetch_pipeline()
self._check_result_for_fetch()
assert self.pgresult
return records
async def fetchall(self) -> List[Row]:
+ """
+ Return all the remaining records from the current recordset.
+
+ :rtype: Sequence[Row], with Row defined by `row_factory`
+ """
await self._fetch_pipeline()
self._check_result_for_fetch()
assert self.pgresult
yield row
async def scroll(self, value: int, mode: str = "relative") -> None:
+ """
+ Move the cursor in the result set to a new position according to mode.
+
+ If `!mode` is ``'relative'`` (default), `!value` is taken as offset to
+ the current position in the result set; if set to ``'absolute'``,
+ `!value` states an absolute target position.
+
+ Raise `!IndexError` in case a scroll operation would leave the result
+ set. In this case the position will not change.
+ """
await self._fetch_pipeline()
self._scroll(value, mode)
writer: Optional[AsyncCopyWriter] = None,
) -> AsyncIterator[AsyncCopy]:
"""
+ Initiate a :sql:`COPY` operation and return an object to manage it.
+
:rtype: AsyncCopy
"""
try:
except e._NO_TRACEBACK as ex:
raise ex.with_traceback(None)
+ # If a fresher result has been set on the cursor by the Copy object,
+ # read its properties (especially rowcount).
self._select_current_result(0)
async def _fetch_pipeline(self) -> None: