3 ms·
With SQLite, I've started using json_each on a JSON parameter for bulk inserts or updates. Other SQL databases should have something similar. It's much cleaner
by matharmin 4y ago
With SQLite, I've started using json_each on a JSON parameter for bulk inserts or updates. Other SQL databases should have something similar.
It's much cleaner than generating SQL, and doesn't run into issues with exceeding the maximum number of parameters.
- plugin-baby 4y agoThis sounds very neat. Do you have an example handy?
- fragile_frogs 4y agoThis is what I do in postgres: insert into your_table(id, created_at, uri, project_id) select id , created_at , endpoint as uri , project_id from jsonb_to_recordset($1) as x( id uuid , created_at timestamptz , endpoint text , project_id uuid )