stair_spirit
stair_spirit12mo ago

Loop over all items in previous result and write each as a (postgres) db in flow

Hi, can anyone please share any examples or hints for looping over a number of objects (like 5k+) in the previous result and writing each as a row in a db? I can of course link the inputs in my inline postgresql flow action to each item like results.b.reports[0].someValue but that will insert only the one row for reports[0]. I would like to repeat this and insert a row for as many objects as exist.
5 Replies
rubenf
rubenf12mo ago
Hi have you tried using the forloop of the flows ?
stair_spirit
stair_spiritOP12mo ago
Ah, sorry, I think I just realised I can use a for loop block... Is that the most efficient way? I intend to write thousands of rows
rubenf
rubenf12mo ago
The most efficient would be to do a forloop inside your script
stair_spirit
stair_spiritOP12mo ago
Thanks - so you mean like have another python script, import the a postgres library, etc?
rubenf
rubenf12mo ago
Yes