Insert rows into a table
- async AsyncCogniteClient.raw.rows.insert(
- db_name: str,
- table_name: str,
- row: Sequence[Row] | Sequence[RowWrite] | Row | RowWrite | dict,
- ensure_parent: bool = False,
Insert one or more rows into a table.
- Parameters:
Examples
Insert new rows into a table:
>>> from cognite.client import CogniteClient >>> from cognite.client.data_classes import RowWrite >>> client = CogniteClient() >>> # async_client = AsyncCogniteClient() # another option >>> rows = [ ... RowWrite(key="r1", columns={"col1": "val1", "col2": "val1"}), ... RowWrite(key="r2", columns={"col1": "val2", "col2": "val2"}), ... ] >>> client.raw.rows.insert("db1", "table1", rows)
You may also insert a dictionary directly:
>>> rows = { ... "key-1": {"col1": 1, "col2": 2}, ... "key-2": {"col1": 3, "col2": 4, "col3": "high five"}, ... } >>> client.raw.rows.insert("db1", "table1", rows)