Rather than hard-coding the ON CONFLICT DO UPDATE statements, inject a tuple to generate the statements dynamically.
Breaking Change
Before:
# boolean parameter specified at initialization time
loader = ProviderDataLoader(on_conflict_update=True)
# use the configured loader to load some data
loader.load_trips(data)
or
# initialize without the parameter
loader = ProviderDataLoader()
# boolean parameter used at load time
loader.load_trips(data, on_conflict_update=True)
Now:
# initialize without the parameter
loader = ProviderDataLoader()
# what is in conflict
condition = "(provider_id, trip_id)"
# the column updates to make
# (as a dict)
actions = { "route": "EXCLUDED.route", "start_time": "EXCLUDED.start_time" }
# (or a list)
actions = ["route = EXCLUDED.route", "start_time = EXCLUDED.start_time"]
# (or a simple str)
actions = "route = EXCLUDED.route, start_time = EXCLUDED.start_time"
# tuple parameter used at load time
loader.load_trips(data, on_conflict_update=(condition, actions))
Rather than hard-coding the
ON CONFLICT DO UPDATE
statements, inject a tuple to generate the statements dynamically.Breaking Change
Before:
or
Now: