So I am inserting to database using mysql connector,
I have been using but I was suggested to use char buffer, and sprintf() to populate it will not fragment memory the way that Strings can.
so I took a look in mysql arduino example sketch and it uses this:
const char INSERT_DATA = "INSERT INTO test_arduino.temps VALUES (%s, NULL)";
INSERT_DATA i.e the query storing variable is declared char of indefinite length !
and later used sprintf
char query; char temperature; dtostrf(value_read, 1, 1, temperature); sprintf(query, INSERT_DATA, temperature);
looking at the insert query it has %s so does that mean in the call to function sprintf the value of temperature is inserted to INSERT_DATA and then it is fed to the query variable which is the first in call to sprintf ?
thats what I don't get ? I am not cpp programmer I have been programming with python and still thinking like a python programmer , so any help would be greatly appreciated