"Inserting in a loop is a bad idea" would have been a more real title.
The moment your insertions can be done in a loop, _batch them_. Batch them, batch them, batch them. I can't stress this enough. Batch them.
Do keep in mind that your DBMS of choice can have a maximum amount of bound variables (SQLite has 999 maximum by default if I remember correctly. It can quickly become an issue.) If you fear that this might happen, split into multiple batches, batch those batches.
> timestamp TEXT
> PRIMARY KEY(timestamp, ...)
Dear god no. Make it an actual `timestamp` type, or an int if you can't.