iter_tuple

iter_tuple returns a generator that reads one row at a time from a table into a named tuple. The named tuple contains fields with column names as their names and values from columns.

If locking is not explicitly specified, this method will automatically lock to ensure that all data from an iteration is from a consistent table snapshot.

Syntax

Parameters

ParameterTypeDescription
colsUnion[str, Sequence[str]]

The columns to read. If not given, all columns are read. The default is None, which reads all columns.

tuple_namestr

The name of the named tuple. The default is "Deephaven".

chunk_sizeint

The number of rows to read at a time internally by the engine. The default is 2048.

Examples

The following example iterates over a table and prints the values of each row.

The following example iterates over only two of three columns from a table.

The following example iterates over two of three columns in a table. The values are unpacked in the for loop itself. Because columns are specified in the function call, the code is tolerant of schema ordering changes.

The following example iterates over a table and renames the named tuple to my_tuple.