I'm getting an error when trying to import data from a csv into a MariaDB:
Error: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'ANTHRAZIT', 'undefined', '9,16', '0,000', '0,000', '0,000', '1,000', '1' at line 1
Therefore I'm trying to remove the ' in the SQL statement (which is generated) prior to connecting to the DB using:
I also tried:
var str = msg.topic;
var res = str.replace(/[']/gi, '');
msg.topic = res;
return msg;
and various variations.
Can anyone pls tell me how to search for ' and replace it with nothing or any character which will not crash my INSERT into SQL?
msg.payload is an array and inside of these objects are values from a csv, chunked via chunks-to-lines node of which the output is text.
After the sql function, msg.topic is set to be the same as msg.payload so it functions with the sql node.
replace() is a function that must be called on a string, not an array. If you want to call it on all the elements of an array then look at the function Array.map()