'How to use upsert command in django for bulkupdate?
I need to update 1000's of rows each with differant values in timescale db.
I found bulk update to do so.
list = ModelClass.objects.filter(name = 'bar')
obj_to_be_update = []
for obj in list:
obj.name = "Dear "+obj.name
obj_to_be_update.append(obj)
ModelClass.objects.bulk_update(obj_to_be_update, ['name'], batch_size=1000)
This takes alot of time to update and even atomic transaction took alot time to update in the db.
Instead found upsert for timescale db which does execution faster. Any idea how to do it in django.
https://docs.timescale.com/timescaledb/latest/how-to-guides/write-data/upsert/#upsert-functionality
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
