Line break Mysql query

Is there a way to line break the sql query for the node-red-node-mysql node.
The mysql query is a string that's assigned to the msg.topic. Some query 's are that long that you get lost in the editor screen.
For now I break up the string with "+" , but that's also not ideal and sensitive to errors.

Somebody a better idea?

If it helps...
For my lenghly insert-queries I use a UI-template node connected to the mysql node.
Make sure to set the property as... msg.topic

INSERT INTO node_summary (uniqueID, date, time, deviceID, nodeID, location, deviceType, power_source, input_voltage, regulated_voltage, temperature, humidity, pressure, co2, python_script, oled_contents) VALUES (
'{{uniqueID}}',
'{{date}}',
'{{time}}',
'{{deviceID}}',
'{{nodeID}}',
'{{location}}',
'{{deviceType}}',
'{{power_source}}',
'{{input_voltage}}',
'{{regulated_voltage}}',
'{{temperature}}',
'{{humidity}}',
'{{pressure}}',
'{{co2}}',
'{{python_script}}',
'{{oled_contents}}'
)

ON DUPLICATE KEY UPDATE
uniqueID='{{uniqueID}}',
date='{{date}}',
time='{{time}}',
deviceID='{{deviceID}}',
nodeID='{{nodeID}}',
location='{{location}}',
deviceType='{{deviceType}}',
power_source='{{power_source}}',
input_voltage='{{input_voltage}}',
regulated_voltage='{{regulated_voltage}}',
temperature='{{temperature}}',
humidity='{{humidity}}',
pressure='{{pressure}}',
co2='{{co2}}',
python_script='{{python_script}}',
oled_contents='{{oled_contents}}'
2 Likes

Depends what part of the query.

If you are talking about the values, then yes. Do NOT generate SQL inserts or updates (or any kind) using strings (they are at risk of SQL Injection hacks / bad practice). Instead, use parameters (prepared queries).

It is detailed on the README and there are tonnes of examples in the forum.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.