-
Notifications
You must be signed in to change notification settings - Fork 132
Open
Description
I use the library on some sensors with inserts, call procedures (even with return values) without any problems.
But I can't get a "simple" select to work. :(
Hard-/Software:
ESP8266 (wemos d1 mini) with some sensors and a relay card.
Arduino IDE 2.3.4
MySQL Connector Arduino 1.2.0
MySQL 5.1.73 - Source distribution
void setup() {
...
// connecting to MySQL
MySQL_Connection conn((Client *)&client);
Serial.println("Connecting to MySQL...");
if (conn.connect(server_addr, 3306, user, password, db)) {
delay(1000);
} else {
Serial.println("Connection failed.");
delay(2000);
ESP.restart();
}
// Create an instance of the cursor passing in the connection
char query1[200];
char query2[] = "CALL DataCalc();";
char query3[] = "SELECT int_heizkreis, str_mac FROM Wohnung_Messdaten.pipe_sensor_config";
Serial.println("query 1");
MySQL_Cursor *cur_mem = new MySQL_Cursor(&conn);
sprintf(query1, "UPDATE sensor_config SET ts_letzte_meldung = NOW(), str_typ = '%s' WHERE str_mac = '%s'", IP, str_mac);
Serial.println(query1);
cur_mem->execute(query1);
delete cur_mem;
Serial.println("query 2");
MySQL_Cursor *cur_mem2 = new MySQL_Cursor(&conn);
row_values *row2 = NULL;
cur_mem2->execute(query2);
column_names *columns2 = cur_mem2->get_columns();
row2 = cur_mem2->get_next_row();
Relay = atol(row2->values[0]);
Serial.println(Relay,BIN);
IOexpanderWrite(DEVICE_1, Relay);
delete cur_mem2;
Serial.println("query 3");
MySQL_Cursor *cur_mem3 = new MySQL_Cursor(&conn);
row_values *row3 = NULL;
cur_mem3->execute(query3);
Serial.println("Columns start");
column_names *columns3 = cur_mem3->get_columns();
Serial.println("Columns done");
do {
row3 = cur_mem3->get_next_row();
if (row3 != NULL) {
int heizkreis = atoi(row3->values[0]);
byte mac_address[8];
char* mac_str = row3->values[1];
...
}
} while (row3 != NULL);
delete cur_mem3;
conn.close();
}
and the serial output (query 3 is the problematic one)
..[WIFI] STATION Mode, SSID: WiFi1, IP address: 10.10.10.123
Connected to network
MAC-Adresse: 98:f4:ab:db:28:3a
IP-Adresse: 10.10.10.123
serverSetupRelay: 11
Server started
Connecting to MySQL...
...trying...
Connected to server version 5.1.73
query 1
UPDATE sensor_config SET ts_letzte_meldung = NOW(), str_typ = '10.10.10.123' WHERE str_mac = '98:f4:ab:db:28:3a'
query 2
1000000
query 3
Columns start
Bad mojo. EOF found reading column header.
Columns done
ERROR: You must read the columns first!
Disconnected.
Is there any option to skip the columns or fix the error?
Metadata
Metadata
Assignees
Labels
No labels