Skip to content

civex.upsert_records

The older name of civex.rows_to_records matching on one field: key_field: number is match_on: [number]. It is kept so workflows saved with it run as they did, and runs the same code; new workflows use civex.rows_to_records, which also takes several key fields and Columns to fields.

Uses pandas, which ships with civex — see civex.parse_table.

Plugin ID: civex.upsert_records
Category: outputs
Capabilities: read, write_records

Config

Field Type Required Default Description
schema string yes Name of the schema to create/update records under. Workflow YAML sets this via the schema: key (the Python field is schema_name).
key_field string yes The field a row and a record must agree on to be the same.
dataset string no "" Dataset to search and create records in. Empty string falls back to the trigger record's own dataset.
parent_record_id string no "" Parent record ID to scope matching and creation to. Empty string falls back to the trigger record's ID.

Inputs

Name Type Required Description
table table yes The table to save. Its columns go into the fields of the same name.

Outputs

Name Type Required Description
created number yes How many records it made.
updated number yes How many rows matched a record and changed it.
unchanged number yes How many rows matched a record that already held their values.
skipped number yes How many rows were not saved.
skipped_rows list yes Why each row not saved was left out: no key value, a key repeated in the table, several records with that key, or a value the record refused.
- id: upsert
  plugin: civex.upsert_records
  config:
    schema: Sample
    key_field: number
  inputs:
    table: parse.table

How rows are matched, what an update keeps and which rows are left out are as described for civex.rows_to_records. A row with no value for the key field is now counted in skipped and named in skipped_rows; it used to be dropped without a word, and a key repeated in the table used to overwrite the earlier row's record.