Skip to content

Commit d25b964

Browse files
author
James William Pye
committed
Add mentions of non-declared cursors.
1 parent 942f156 commit d25b964

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

postgresql/documentation/driver.txt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -833,7 +833,9 @@ Cursors
833833
When a prepared statement is declared, ``ps.declare(...)``, a
834834
`postgresql.api.Cursor` is created and returned for random access to the rows in
835835
the result set. Direct use of cursors is primarily useful for applications that
836-
need to implement paging.
836+
need to implement paging. For situations that need to iterate over the result
837+
set, the ``ps.rows(...)`` or ``ps.chunks(...)`` execution methods should be
838+
used.
837839

838840
Cursors can also be created directly from ``cursor_id``'s using the
839841
``cursor_from_id`` method on connection objects::
@@ -844,6 +846,10 @@ Cursors can also be created directly from ``cursor_id``'s using the
844846
[(1,)]
845847
>>> c.close()
846848

849+
.. hint::
850+
If the cursor that needs to be opened is going to be treated as an iterator,
851+
then a FETCH-statement should be prepared instead using ``cursor_from_id``.
852+
847853
Like statements created from an identifier, cursors created from an identifier
848854
must be explicitly closed in order to destroy the object on the server.
849855
Likewise, cursors created from statement invocations will be automatically

0 commit comments

Comments
 (0)