Bulk update in SQLAlchemy on a JSONB column

Viewed 171

What is the correct way of updating multiple rows - specifically the JSONB field inside the row without setting the whole column (but adding new keys to the JSONB column)?

Something like -

data_mappings = [{
    'id': 1, 
    'dynamic': {'new_key': 'some_value'}
}, ...]

session.bulk_update_mappings(Data, data_mappings)
session.commit()

The 'dynamic' column should remain with the old data and will have the new_key in it.

0 Answers
Related