Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

sql.postgres.cursor

import sql.postgres.cursor

sql lifts part of this module out to its own top level; each name below is shown with the path that reaches it. Anything still spelled sql.postgres.cursor.* needs import sql.postgres.cursor.

Reading a PostgreSQL result a batch at a time.

The server holds the result in a portal and sends as many rows as each Execute asks for. When more remain it says so, and the next Execute continues where the last stopped. Nothing but the current batch is ever held on this side.

Classes

PostgresCursor

class sql.postgres.PostgresCursor < DriverCursor

A portal being read.

  • printable — has a @to_string(), so echo and print() show something useful

Constructor

sql.postgres.PostgresCursor(connection, state)

Parameters

  • connection (PostgresConnection)
  • state (dict) — The portal’s name, its columns, the first batch of rows, whether more remain, and whether this cursor opened the transaction it is running in.

PostgresCursor.columns()

sql.postgres.PostgresCursor.columns()

PostgresCursor.next_row()

sql.postgres.PostgresCursor.next_row() -> list|nil

The next row as a list of values, or nil once the result is finished.

Returns list|nil

PostgresCursor.close()

sql.postgres.PostgresCursor.close()

Releases the portal, and the transaction if this cursor opened one. Safe to call more than once.

PostgresCursor.is_closed()

sql.postgres.PostgresCursor.is_closed() -> bool

Whether the cursor has been closed or read to the end.

Returns bool

PostgresCursor.to_string()

sql.postgres.PostgresCursor.to_string()

2026, Richard Ore and Zuri contributors