Go Down

Topic: MySQL memory (Read 142 times) previous topic - next topic

phods

May 18, 2017, 10:55 pm Last Edit: May 18, 2017, 11:02 pm by phods
I'm using the code below, to make a select in a mysql database,
and I receive a error of "Memory error.", because  the table has 25 columns if a I try in an table with less than 15 columns , its run ok.
how can I fix?


Code: [Select]
// Initiate the query class instance
  MySQL_Cursor *cur_mem = new MySQL_Cursor(&conn);
  // Execute the query
  cur_mem->execute("SELECT * FROM log WHERE 1");
  // Fetch the columns and print them
  column_names *cols = cur_mem->get_columns();
  Serial.println("colunas");
  for (int f = 0; f < cols->num_fields; f++) {
    Serial.print(cols->fields[f]->name);
    if (f < cols->num_fields-1) {
      Serial.print(", ");
    }
  }
  Serial.println();
  // Read the rows and print them
  Serial.println("linhas");
  row_values *row = NULL;
  do {
    row = cur_mem->get_next_row();
    if (row != NULL) {
      for (int f = 0; f < cols->num_fields; f++) {
        Serial.print(row->values[f]);
        if (f < cols->num_fields-1) {
          Serial.print(", ");
        }
      }
      Serial.println();
    }
  } while (row != NULL);
  // Deleting the cursor also frees up memory used
  delete cur_mem;

Kingside

maybe to get 15 columns, do what ever you want and then get the others?

PaulS

Quote
how can I fix?
Make a GET request to a PHP script. Stop trying to do everything on the Arduino.
The art of getting good answers lies in asking good questions.

Go Up