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:
objectResult 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.
- keys()[source]
Get column names