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.sqlite.cursor

import sql.sqlite.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.sqlite.cursor.* needs import sql.sqlite.cursor.

Reading a SQLite result one row at a time.

SQLite computes rows as they are asked for rather than building the whole result first, so a cursor here is the engine’s own behaviour exposed rather than a batching scheme layered on top. A query over a large table holds one row at a time however long the table is.

The statement a cursor is stepping belongs to it until it closes. That is why the connection compiles a separate statement for each cursor rather than lending one from its cache.

Classes

SqliteCursor

class sql.sqlite.SqliteCursor < DriverCursor

A result being stepped.

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

Constructor

sql.sqlite.SqliteCursor(statement, columns, conversions, query, owned)

Parameters

  • ptr — statement A prepared native statement, already bound.
  • columns (list) — Column descriptors.
  • conversions (list) — Per column conversions.
  • query (string) — The statement, for error messages.
  • owned (bool) — Whether closing the cursor finalizes the statement, which it does for a cursor the connection compiled and does not for one belonging to a prepared statement the caller still holds.

SqliteCursor.columns()

sql.sqlite.SqliteCursor.columns()

SqliteCursor.next_row()

sql.sqlite.SqliteCursor.next_row() -> list|nil

The next row, or nil once the result is finished.

Reaching the end closes the cursor, so a loop that runs to exhaustion releases the statement without having to remember to.

Returns list|nil

SqliteCursor.close()

sql.sqlite.SqliteCursor.close()

Releases the cursor. Safe to call more than once, and safe to call on a cursor that already ran to the end.

SqliteCursor.is_closed()

sql.sqlite.SqliteCursor.is_closed() -> bool

Whether this cursor has been closed or run to exhaustion.

Returns bool

SqliteCursor.to_string()

sql.sqlite.SqliteCursor.to_string()

2026, Richard Ore and Zuri contributors