Multi insert best practice

Hi, I need to do insert transactions that contain many rows (usually less than 1000).
In the documentation says the recommended way is to do them in one batch, something like INSERT INTO users ( id, name) VALUES (1, ‘Paul’), (2, ‘Susan’) …

I could do that joining strings, but that way there is a risk of sql injections.

I’m using Golang. ¿what’s the best way to do it?

Hi marcos,

you didn’t write, which library you’re using in your project.

In case you’re dealing with the standard database/sql lib, which pq is based on,
I recommend having a look at
this github issue/question

In pq directly, it would be possible to make use of the bulk import feature. Some example code can be found here:
Bulk imports in pq

Hope this helps anybody.