Mysql database w/ arduino uno and nodemcu ESP8266 D1

I started a project w Uno and Nodemcu but have no programming skills.
What I want to do is to post records in to a mysql database.

I found this code finally.

 #include <ESP8266WiFi.h>
 #include <WiFiClient.h>
 #include <MySQL_Connection.h>
 #include <MySQL_Cursor.h>
 IPAddress server_addr(;   // IP of the MySQL server
 char user[] = "root";                     // MySQL user login username
 char password[] = "";                 // MySQL user login password
 // WiFi card example
 char ssid[] = "TP-LINK_C9BA6C";                     // your SSID
 char pass[] = "1968Jan13";                     // your SSID Password
 // Sample query
 char INSERT_SQL[] = "INSERT INTO `util_db`(`Count`, `Unit_id`, `DateTime`) VALUES (count, unit_id, Date)";
 WiFiClient client;
 MySQL_Connection conn((Client *)&client);
 void setup() {
   WiFi.begin(ssid, pass);                      // initializing the WIFI library
   while ( WiFi.status() != WL_CONNECTED ) {    // while loop to write dots during connecting
     delay ( 500 );
     Serial.print ( "." );
   // print out information about the WIFI connection
   Serial.println ( "" );
   Serial.print ( "Connected to " );
   Serial.println ( ssid );
   Serial.print ( "IP address: " );
   Serial.println ( WiFi.localIP() );
   // connecting to the MySQL server
   Serial.println("DB - Connecting...");
   while (conn.connect(server_addr, 3306, user, password) != true) {
     Serial.print ( "." );
 void loop() {
   Serial.println("Recording data.");
   // Initiate the query class instance
   MySQL_Cursor *cur_mem = new MySQL_Cursor(&conn);
   delete cur_mem;

So then I realized that this is for an Uno w an inbuilt ESP8266.

My questions are,

  • How to connect Uno and Nodemcu for this.
  • What is the correct way of writing this code for the above mentioned way?

Thanks guys I really appreciate your help.

some help here? :cry:

Why don't you just buy an ESP8266 shield for your Uno since you already own one and then the above code should do what you want?

So then I realized that this is for an Uno w an inbuilt ESP8266.

No, what makes you think that? It's code for programming the ESP8266 directly, e.g. a NodeMCU or Wemos D1 mini.

I prefer using HTTP requests to the server, instead of running a MySQL connector on the ESP8266.
This is my code: