List rows in a table
- async AsyncCogniteClient.raw.rows.list(
- db_name: str,
- table_name: str,
- min_last_updated_time: int | None = None,
- max_last_updated_time: int | None = None,
- columns: list[str] | None = None,
- limit: int | None = 25,
- partitions: int | None = None,
-
- Parameters:
db_name (str) – Name of the database.
table_name (str) – Name of the table.
min_last_updated_time (int | None) – Rows must have been last updated after this time (exclusive). Milliseconds since epoch.
max_last_updated_time (int | None) – Rows must have been last updated before this time (inclusive). Milliseconds since epoch.
columns (list[str] | None) – List of column keys. Set to None to retrieving all, use empty list, [], to retrieve only row keys.
limit (int | None) – The number of rows to retrieve. Can be used with partitions. Defaults to 25. Set to -1, float(“inf”) or None to return all items.
partitions (int | None) – Retrieve rows in parallel using this number of workers. Can be used together with a (large) finite limit. When partitions is not passed, it defaults to 1, i.e. no concurrency for a finite limit and
global_config.concurrency_settings.raw.readfor an unlimited query (will be capped at this value). To prevent unexpected problems and maximize read throughput, check out concurrency limits in the API documentation.
- Returns:
The requested rows.
- Return type:
Examples
List a few rows:
>>> from cognite.client import CogniteClient, AsyncCogniteClient >>> client = CogniteClient() >>> # async_client = AsyncCogniteClient() # another option >>> row_list = client.raw.rows.list("db1", "tbl1", limit=5)
Read an entire table efficiently by using concurrency (default behavior when
limit=None):>>> row_list = client.raw.rows.list("db1", "tbl1", limit=None)
Iterate through all rows one-by-one to reduce memory load (no concurrency used):
>>> for row in client.raw.rows("db1", "t1", columns=["col1", "col2"]): ... val1 = row["col1"] # You may access the data directly ... val2 = row.get("col2") # ...or use '.get' when keys can be missing
Iterate through all rows, one chunk at a time, to reduce memory load (no concurrency used):
>>> for row_list in client.raw.rows("db1", "t1", chunk_size=2500): ... row_list # Do something with the rows
Iterate through a massive table to reduce memory load while using concurrency for high throughput. Note:
partitionsmust be specified for concurrency to be used (this is different fromlist()to keep backward compatibility). Supplying a finitelimitdoes not affect concurrency settings (except for very small values).>>> rows_iterator = client.raw.rows( ... db_name="db1", table_name="t1", partitions=5, chunk_size=5000, limit=1_000_000 ... ) >>> for row_list in rows_iterator: ... row_list # Do something with the rows