Sync
- async AsyncCogniteClient.data_modeling.records.sync(
- stream_id: str,
- *,
- initialize_cursor: str,
- filter: Filter | None = None,
- sources: Sequence[RecordSourceSelector] | None = None,
- target_units: RecordTargetUnits | Sequence[RecordTargetUnit] | None = None,
- limit: int = 10,
- include_typing: bool = False,
-
Returns the first page of the change feed (new, updated and deleted records). Provide
initialize_cursorto start from a relative time such as"7d-ago". Persist the returnedSyncRecordList.cursorand pass it tosync_resume()on the next call to continue;SyncRecordList.has_nextindicates whether more changes are immediately available.- Parameters:
stream_id (str) – External ID of the stream to sync.
initialize_cursor (str) – Where to start, as a relative duration like
"7d-ago".filter (Filter | None) – Filter expression (see
cognite.client.data_classes.filters).sources (Sequence[RecordSourceSelector] | None) – Which container properties to return.
target_units (RecordTargetUnits | Sequence[RecordTargetUnit] | None) – Properties to convert to another unit.
limit (int) – Maximum number of records to return in this page (1-1000). Defaults to 10.
include_typing (bool) – If True, include property type information on the returned list’s
typingattribute.
- Returns:
One page of change records, with
cursorandhas_nextset.- Return type:
Examples
Initialize a sync, process the page, then resume from the cursor later:
>>> from cognite.client import CogniteClient >>> client = CogniteClient() >>> page = client.data_modeling.records.sync( ... stream_id="my-stream", initialize_cursor="7d-ago" ... ) >>> for record in page: ... pass # process record; record.status is created/updated/deleted >>> next_page = client.data_modeling.records.sync_resume( ... stream_id="my-stream", cursor=page.cursor ... )