ChuckBell / MySQL_Connector_Arduino

Database connector library for using MySQL with your Arduino projects.
332 stars 133 forks source link

get_rows_affected() always returns a -1? #231

Open taper42 opened 3 weeks ago

taper42 commented 3 weeks ago

Hello!

I have been using your connector for some time already - thank you for this marvelous connector!

I wanted these days to see how many rows my query returns and found get_rows_affected() in the src, but absolutely no mention of it on the web tho :) so I tried it and gets me a -1 every time.

Everything else works perfectly, using the "query_results" example, it is fetching all the columns names and values, but the affected rows is -1.

The query is: char query[] = "SELECT * FROM cam.t WHERE DATE (date_opening) = CURDATE() ORDER BY date_opening DESC LIMIT 0 , 100";

and I expect a result of no more than 15 rows on any given day, but there are some 20k records in this table. Today's result is 1 for the first part, now is 2, if that matters.

The query also works perfectly in phpmyadmin. Mysql log shows no error for this query

this is what I added to the example (towards the end of the loop():

  } while (row != NULL);

  // my try for get_rows_affected()
  int nr = cur_mem->get_rows_affected();
  Serial.print("\n\r #: ");
  Serial.print(nr);

  // Deleting the cursor also frees up memory used
  delete cur_mem;
  delay(180000); (any less will trigger the MySQL server  for a day run:)

(and there is the WiFi initialization too, which is standard).

thank you and best regards

ChuckBell commented 2 weeks ago

Hello,

Sorry for the delay. It’s been a rough month.

What version of MySQL are you using? Is it an Oracle distribution? The connector may not work correctly with a non-Oracle distribution. Finally, what version of the connector are you using and have you tried the latest version from GitHub?

Dr. Bell

On Jun 11, 2024, at 4:50 AM, taper42 @.***> wrote:

Hello!

I have been using your connector for some time already - thank you for this marvelous connector!

I wanted these days to see how many rows my query returns and found get_rows_affected() in the src, but absolutely no mention of it on the web tho :) so I tried it and gets me a -1 every time.

Everything else works perfectly, using the "query_results" example, it is fetching all the columns names and values, but the affected rows is -1.

The query is: char query[] = "SELECT * FROM cam.t WHERE DATE (date_opening) = CURDATE() ORDER BY date_opening DESC LIMIT 0 , 100";

and I expect a result of no more than 15 rows on any given day, but there are some 20k records in this table. Today's result is 1 for the first part, now is 2, if that matters.

The query also works perfectly in phpmyadmin. Mysql log shows no error for this query

this is what I added to the example (towards the end of the loop():

} while (row != NULL);

// my try for get_rows_affected() int nr = cur_mem->get_rows_affected(); Serial.print("\n\r #: "); Serial.print(nr);

// Deleting the cursor also frees up memory used delete cur_mem; delay(180000); (any less will trigger the MySQL server for a day run:) (and there is the WiFi initialization too, which is standard).

thank you and best regards

— Reply to this email directly, view it on GitHub https://github.com/ChuckBell/MySQL_Connector_Arduino/issues/231, or unsubscribe https://github.com/notifications/unsubscribe-auth/AB6SHYB2OI4FK6CQW3V244LZG223RAVCNFSM6AAAAABJD3SKUSVHI2DSMVQWIX3LMV43ASLTON2WKOZSGM2DKNZYHA2DIMA. You are receiving this because you are subscribed to this thread.