Note: this example uses the new xdevapi library which uses the X protocol. It can work only with the official MySQL and not with MariaDB. A MariaDB version is available on this repository: https://github.com/stackhero-io/mariadbGettingStarted.
You can find here some examples of Node.js code to send data to a MySQL server.
These examples are designed to run with a Stackhero MySQL service. You'll more informations about Stackhero here:
This example will connect to your MySQL server, create the database stackherotest and the table users and fill it with 1000 fake users datas.
- 
Clone this repository: git clone https://github.com/stackhero-io/mysqlGettingStarted && cd mysqlGettingStarted
- 
Copy the file .env-exampleto.envand fill it with your credentials.
- 
Install dependencies: npm install.
- 
Run the script: npm run start.
You can see the script code in the file app.js and see how it works to use it as an example.