GAZ082
11 September 2025 13:01
1
Hey there. I’m using sqlite for storing my sensor’s readings. Had to create a string this way otherwise i was not able to load multiple records in one go. Heck, i was not able to use the placeholders either. Is there a more elegant way to insert multiple records?
msg.topic = insert into sensor_data (sensor_id, value, type) values (
+ msg.payload.sensor_id + ,+ msg.payload.temperature + ,1),(
+ msg.payload.sensor_id + ,+ msg.payload.humidity + ,2),(
+ msg.payload.sensor_id + ,+ msg.payload.battery + ,3)
return msg;
Thanks!
depending on the flow how you’ve done it is fine?
you could do it like this?
msg.topic = INSERT INTO sensor_data (sensor_id, value, type) VALUES ($1, $2, 1), ($1, $3, 2), ($1, $4, 3);
msg.payload =[msg.payload.sensor_id,msg.payload.temperature,msg.payload.humidity,msg.payload.battery];
return msg;
at the end of the day as long as you got data into the database in a timely fashion its a win
system
Closed
11 December 2025 08:55
3
This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.