Connect and Query MySQL using NodeJS

Hardik Rathod
4 min readSep 16, 2019
Yes!!! They do get along very well.

Hello everyone, I am a Data Engineer who works mainly with Python but then, I was asked to write a whole data processing pipeline in NodeJS. Sounds absurd, right? Because Python is obviously the goto choice for handling data-related jobs. But when I started with the NodeJS code, I had to finish it and I was very glad that I did because from that point on I realized that Node and I have a long way to go together. And, I am convinced that by the end of my series of articles you will strongly consider working with NodeJS. There are multiple reasons which changed my perspective but first, let me guide your focus on connecting and performing actions on your database.

There are a few things that you will have to set up on your side to follow this tutorial.

  1. Download an editor to write your code in. My personal choice is VScode (download VScode). You are free to choose an editor of your choice.
  2. Download MySQL on your local machine (MySQL download)
  3. Set up a new user and password in MySql (link for the same)
  4. Download NodeJS (nodejs download) or you can run the following command
sudo apt-get install nodejs

Once the above mentioned is done, then the machine is ready to use. Now, let's get to the simpler part a.k.a coding.

--

--

Hardik Rathod

Data Scientist at Quantiphi | GCP | Databricks | Google Cloud — Machine Learning Engineer | Google Cloud — Professional Data Engineer | AWS — Cloud Practitioner