title: Node js job to fetch data from sql server and insert into mysql database
body: <p>I want to develop a task in node js which fetch data from table in sql server and insert into table in mysql. This task need to run continuously after certain time period (say after each 5 seconds). Please guide me to achieve this.</p>
  <h1>JS code</h1>
  <pre><code>var sql = require('mssql');
  var mysql = require(&quot;mysql&quot;);
  var config = {
      user: 'user', 
      password: '*****',
      server: 'url', 
      database: 'DB',
      stream: true //work with large amount of rows
  }
  
  var connection1 = mysql.createConnection({
            host     : 'localhost',
            user     : 'root',
            password : 'root',
            database : 'test'
  });
  
  connection1.connect();
  var connection = new sql.Connection(config, function(err) {
  
  if(err)
      console.log(err);
  
  var request = new sql.Request(connection);
  //request.stream = true; // You can set streaming differently for each request 
  
  request.query('select TOP 100000 * FROM ShipmentAuditLog with (nolock)'); // or request.execute(procedure); 
  console.time('Time-Taken');
  
  request.on('recordset', function(recordset) {
      // Emitted once for each recordset in a query 
      //console.log(recordset);
  
  });
  
  request.on('row', function(row) {
      // Emitted for each row in a recordset 
      //console.log(row);
      syncing(row);
  
  });
  
  request.on('error', function(err) {
      console.log(err);
  });
  
  request.on('done', function(returnValue) {
      // Always emitted as the last one
      console.log('Completed');
      console.timeEnd('Time-Taken');
      connection.close();
  
      });
  });
  
  var syncing = function(row){
   connection1.query('INSERT INTO shipmentauditlog SET ?',row,function(err,res){
       if(err)
          console.log(err);
    
    });
  }
  </code></pre>