Allow bulk inserts of records into Retool Database while ignoring (not updating) existing records

Hey Builders of Retool,

the retool database bulk operations (GUI mode) are super helpful.

Unfortunately, it’s not yet possible in GUI mode to do a bulk insert of new rows only (via primary key).

I’d like to bulk insert new rows, and do nothing on rows that already exist - basically the equivalent of Postgres ON CONFLICT DO NOTHING

All the best
Michael

2 Likes

Hi,

Just curious, what component are you using to add these new items?

If it's an editable Table component, you can use its built-in {{ table1.newRows }} property as the data source for that SQL query, which makes it very clean.

Cheers!

2 Likes

Hey Mateusz,

good point for users of the table component in such a scenario. I wasn’t aware that in addition to changesetObject and changesetArray there is also newRows as table component properties - which should allow to treat edited and new rows differently.

My use cases are within Retool Workflows (synchronizing data between an external system and Retool Database) and we need to make this sync tolerant to temporary errors, timeouts, and race conditions. Unfortunately, in these edge cases it’s not trivial to determine which rows are new. A GUI based “bulk insert on primary key or do nothing” would be a very clean solution. But this requires explicit support from Retool side.

Best regards
Michael

@michael_h Thanks for your post.

You are correct - it seems the current bulk insert option for the Retool Database GUI would error if there are conflicting primary keys. At the moment you would either need to use SQL or filter the records before inserting.

Thanks!

1 Like