Nodejs is a powerful platform which used for real-time data with flexible of handling data in file system or database side. Today tutorial we are going to discuss about the connecting MySql with Nodejs.
Before getting into our code part, first will discuss about things needed for MySql connecting with Nodejs then will move to our code side.
First we need to check the MySql package is installed in our current Nodejs version or not. We have the command to check list or individual package installed in Nodejs. If the package is installed it will display the package else show “(empty)” value.
Nodejs have the ability to track the connected and disconnected user IP Address with socket.io node package.
What is Socket.io ?
Socket.io enables real-time directions which is event based communication. Its works on all the platform, browser or device on reliability and speed. We need to check few package it’s installed or not. if not you can install socket.io and ip both package from your terminal.
Installing socket.io package
Installing ip package
Once you have installed both the packages, let’s include our needed package into our code and create server where our code will on that port.
var app = require('http').createServer(handler),
io = require('socket.io').listen(app),
ip = require('ip');
For example I need to refresh the data, whenever new data is added or update in database. But ajax calls will refresh the data based on the interval.
After that I came to know its not proper way to go, because refresh data means whenever new data got inserted or updated it should be reflected.
So I switched over to Nodejs for real-time data stuff, before installing Nodejs.
We will have brief discuss about it.
What is Nodejs ?