psycopg.git / summary / log / commit / refs

commit    e1e801026eefb4a922cd16f69a22196ca72ca1cc
Author:   Daniele Varrazzo <daniele.varrazzo@gmail.com>
Date:     Wed Feb 10 01:18:51 2021 +0000

    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 a1f0d951..1b7f7a01 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 05cdc600..b341f03a 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 [parent: 4e74d749ab43]