I'm new to C ++ and MySQL, so if the answer is relativly simple, then I'm sorry in advanced , But I can not find any (work) solution yet, though I know that it must be done.
I am trying to log the data from my sensor to a local host MySQL database on Raspberry. To maintain good performance, many Datapoint SQL documents should be written to be executed only one. At the moment I am using this method for 50 signal points / second:
{i = 0; J = 1; K = 1; / * Creating Pstmt Statement * / pstmt = con- & gt; Ready Statement ("INSERT Signal_" + day + "_ + +" _ "+ year +" (ID, sign) value (?,?), (?,?), (?,?), (?,? ), (?,?), (?,?), (?,?), (?,?), (?,?), (?,?), (?,?), (?,?), (?,?), (?,?), (?,?)?), (?,?), (?,?), (?,?), (?,?), (?,?), (?,?), (?,?), (?,?), (?,?), (?,?), (? ,?), (?,?), (?,?), (?,?), (?,?), (?,?), (?,?), (?,? ), (?,?), (?,?), (?,?), (?,?), (?,?), (?,?), (?,?), (?,? ); / * 50 Value Insert / (I and LT; 50) Enter the id integer (j = location, index [i]) * / pstmt-> setInt (j, index [i]) ; K = J + 1; / * Insert the signal integer (k = location, sign [i]) * / pstmt-> SETIINT (K, SIG Execute pstmt by using j = j + 2; i ++;} / * set values * / pstmt- & gt; Execute ();}
* While the first array is being written to SQL, the second array will be filled, then the second will be written in SQL and will be filled again first.
This example works for a datapoint and an index, But if I want to extend the data in 200 digits / seconds and adding a timestamp will be very messy.
So my question: Is the MySQL database easy to access the entire array in 1? (The final goal will be an array with 10 columns and 200 rows / seconds if the display is quite good, but less than 50 / sec)
After proper research, I found a way to insert a SER into MySQL:
zero log_the_data () int i; String Query; {Fprintf (f_log, "% ld% d% s% ld% s \ n", nr_pts ++, data [i], t_string, packet_counter, for i (i = 0; i & lt; 50; i ++) S_status); Stringstream ss; SS & lt; & Lt; "(" & Lt; & lt; nr_pts executed (); afflush (f_log); clear_my_buffer ();
In this, 50 rows in 1 row Is inserted and can be easily expanded
Please correct me if this is not the appropriate way to do it
No comments:
Post a Comment