From e1e801026eefb4a922cd16f69a22196ca72ca1cc Mon Sep 17 00:00:00 2001 From: Daniele Varrazzo Date: Wed, 10 Feb 2021 02:18:51 +0100 Subject: [PATCH] Add docs for Cursor.scroll() --- docs/cursor.rst | 3 +++ psycopg3/psycopg3/cursor.py | 10 ++++++++++ 2 files changed, 13 insertions(+) diff --git a/docs/cursor.rst b/docs/cursor.rst index a1f0d9515..1b7f7a012 100644 --- a/docs/cursor.rst +++ b/docs/cursor.rst @@ -127,8 +127,10 @@ The `!Cursor` class .. automethod:: fetchmany .. automethod:: fetchall .. automethod:: nextset + .. automethod:: scroll .. autoattribute:: pgresult + .. rubric:: Information about the data .. attribute:: description @@ -192,6 +194,7 @@ The `!AsyncCursor` class .. automethod:: fetchone .. automethod:: fetchmany .. automethod:: fetchall + .. automethod:: scroll .. note:: You can also use ``async for record in cursor: ...`` to iterate on the async cursor results. diff --git a/psycopg3/psycopg3/cursor.py b/psycopg3/psycopg3/cursor.py index 05cdc6001..b341f03a6 100644 --- a/psycopg3/psycopg3/cursor.py +++ b/psycopg3/psycopg3/cursor.py @@ -570,6 +570,16 @@ class Cursor(BaseCursor["Connection"]): yield row 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. + """ self._scroll(value, mode) @contextmanager -- 2.47.2