liveBook · Manning

Database result set

As explained in Python Concurrency with asyncio

A database result set is the collection of rows produced by executing a database query.

A database result set is the collection of rows produced by a query. With asyncpg, fetch loads all rows into memory as asyncpg Record objects, whose fields can be accessed by column name. section 5.4

Choose the retrieval approach according to the result set’s size and access needs:

  • Use fetch() for all rows, or fetchrow() when a single record is expected. section 5.4
  • Use a cursor to stream large result sets incrementally, reducing application memory use while increasing database network round trips. section 5.7

Selecting brands

After inserting two brands, fetch() returns records that can be printed by column name: id: 1, name: Levis; id: 2, name: Seven.

How Python Concurrency with asyncio covers it

How deep it goes
Explains in-memory fetching, single-row retrieval, and cursor-based streaming, without detailing cursor internals.
Examples
Demonstrates selecting inserted brands and printing their identifiers and names.
What it assumes
Assumes basic SQL querying and asynchronous Python, while introducing asyncpg records, cursors, and asynchronous iteration.
What you can do after
Apply result retrieval via asyncpg, selecting between complete fetching, single-row access, and streaming.
How it connects
Connects result sets to asyncpg, database queries, cursors, and asynchronous generators.

Also explained in

Compare how 4 books explain database result set →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Python Concurrency with asyncio. The section links point to the parts of the book it draws on.