liveBook · Manning

Cursor

A database cursor is an object or interface that executes database operations and incrementally retrieves or traverses their result rows.

How 7 Manning books explain it

A Pythonic Adventure: From Python basics to a working web app

A database cursor is an object that executes database statements and retrieves their results.

How it is used
Uses a cursor to execute SQL commands while connecting a Flask application to a SQLite orders database.
How deep it goes
Defines the cursor through an analogy and demonstrates creation and execution, while explicitly deferring deeper details.
Examples
Demonstrates CREATE TABLE, INSERT orders, and SELECT-based retrieval in an order-tracking application.
What you can do after
Operate/configure a cursor to execute table-creation, insertion, and selection commands in a SQLite-backed Flask application.

Read how A Pythonic Adventure: From Python basics to a working web app explains cursor →

Learn SQL in a Month of Lunches

A database cursor is a database programming construct that enables query-result data to be processed one row at a time.

How it is used
Processes SELECT results one row at a time when individual evaluation or per-row procedure calls are required.
How deep it goes
Explains the DECLARE, OPEN, FETCH, and CLOSE lifecycle through a complete stored-procedure loop and end-of-results handler.
Examples
Uses order IDs to total quantities sold at list price and scenarios involving California orders, first orders, and customer messages.
What you can do after
Evaluate/understand cursor-based stored procedures and decide when a set-based query can replace row-by-row processing.

Read how Learn SQL in a Month of Lunches explains cursor →

Practices of the Python Pro

A database cursor is an object that executes database statements and provides access to their results.

How it is used
Executes SQL statements and exposes query results within a reusable persistence-layer helper.
How deep it goes
Defines cursor behavior, demonstrates execution and transactions, and stops short of explaining cursor internals.
Examples
Uses a DatabaseManager._execute method to run parameterized SQL through a cursor.
What you can do after
Build reusable SQLite statement execution that returns query results and supports parameter values.

Read how Practices of the Python Pro explains cursor →

Coding with AI

A database cursor is an object that executes database statements and accesses their results through an established connection.

How it is used
Uses cursors to connect Flask route handlers and model methods to SQLite queries and returned page data.
How deep it goes
Explains cursor creation, query use, dependency passing, and connection cleanup, but stops short of database-driver internals.
Examples
Demonstrates selecting records, fetching questions, rendering results, generating question sets, and correcting cursor-related import and constructor errors.
What you can do after
Operate/configure database-backed Flask code by passing a live cursor into models, fetching records, and closing connections safely.

Read how Coding with AI explains cursor →

API Design Patterns

A cursor is a position marker that identifies the point from which the next portion of paged data should be retrieved.

How it is used
Guides consumers through collection pages or chunks of a large resource.
How deep it goes
Defines termination, opacity, empty-page behavior, and large-resource continuation, without specifying one token representation.
Examples
Uses multi-page resource retrieval, empty-result responses, and chunked attachment reads.
What you can do after
Operate pagination by passing returned tokens and stopping only when the next token is empty.

Read how API Design Patterns explains cursor →

MongoDB 8.0 in Action, Third Edition

A cursor is an object representing an incremental result set from a database query and providing methods for traversing its documents.

How it is used
Handles large query results through incremental, batched retrieval and supports automatic or manually controlled document traversal.
How deep it goes
Explains cursor creation, batching, lazy loading, automatic display, manual iteration, and read timeouts without detailing driver internals.
Examples
Uses routes queries, mongosh display behavior, manualIteration(), and a sample_mflix change-stream cursor.
What you can do after
Apply it via mongosh to retrieve query results incrementally, choose manual traversal, and monitor change-stream events.

Read how MongoDB 8.0 in Action, Third Edition explains cursor →

Python Concurrency with asyncio

A database cursor is an object that traverses and retrieves rows from a database query result, potentially incrementally.

How it is used
Streams large PostgreSQL query results when pagination or full-result loading creates memory, query, or database-load concerns.
How deep it goes
Explains pointer-style traversal, asynchronous iteration, prefetching, skipping, and batching, but not cursor internals.
Examples
Uses a product query to stream 1,000 rows, skip 500 rows, fetch 100, or print the first five.
What you can do after
Operate/configure asyncpg cursors inside transactions to stream, skip, batch, and limit retrieved rows.

Read how Python Concurrency with asyncio explains cursor →

Related concepts

These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.