Result Set

This section documents the result set classes that provide query result handling capabilities.

ResultSet

class matrixone.client.ResultSet(columns: List[str], rows: List[Tuple[Any, ...]], affected_rows: int = 0)[source]

Bases: object

Result set wrapper for query results from MatrixOne database operations.

This class provides a convenient interface for accessing query results with methods similar to database cursor objects. It supports both SELECT queries (returning data) and DML operations (returning affected row counts).

Key Features:

  • Iterator interface for row-by-row access

  • Bulk data access methods (fetchall, fetchmany)

  • Column name access and metadata

  • Affected row count for DML operations

  • Cursor-like positioning for result navigation

Attributes:

columns (List[str]): List of column names in the result set
rows (List[Tuple[Any, ...]]): List of tuples containing row data
affected_rows (int): Number of rows affected by DML operations

Usage Examples:

# SELECT query results >>> result = client.execute(“SELECT id, name, age FROM users WHERE age > ?”, (25,)) >>> print(f”Found {len(result.rows)} users”) >>> for row in result.fetchall(): … print(f”ID: {row[0]}, Name: {row[1]}, Age: {row[2]}”)

# Access by column name >>> for row in result.rows: … user_id = row[result.columns.index(‘id’)] … user_name = row[result.columns.index(‘name’)]

# DML operation results >>> result = client.execute(“INSERT INTO users (name, age) VALUES (?, ?)”, (“John”, 30)) >>> print(f”Inserted {result.affected_rows} rows”)

# Iterator interface >>> for row in result: … print(row)

Note: This class is automatically created by the Client’s execute() method and provides a consistent interface for all query results.

__init__(columns: List[str], rows: List[Tuple[Any, ...]], affected_rows: int = 0)[source]
fetchall() List[Tuple[Any, ...]][source]

Fetch all remaining rows

fetchone() Tuple[Any, ...] | None[source]

Fetch one row

fetchmany(size: int = 1) List[Tuple[Any, ...]][source]

Fetch many rows

scalar() Any[source]

Get scalar value (first column of first row)

keys()[source]

Get column names

AsyncResultSet

class matrixone.async_client.AsyncResultSet(columns: List[str], rows: List[Tuple], affected_rows: int = 0)[source]

Bases: object

Async result set wrapper for query results

__init__(columns: List[str], rows: List[Tuple], affected_rows: int = 0)[source]
fetchall() List[Tuple][source]

Fetch all remaining rows

fetchone() Tuple | None[source]

Fetch one row

fetchmany(size: int = 1) List[Tuple][source]

Fetch many rows

scalar() Any[source]

Get scalar value (first column of first row)

keys()[source]

Get column names