title: Inserting bulk data into MySQL using node JavaScript
body: <p>I am trying to fetch data from SQL server and insert into MySQL. I have fetching around 1 lac's record. Fetching of record is done correctly but during insertion of records into MySQL it will not insert data at once. I need to refresh MySQL to see new records.</p>
  
  <pre><code>var sql       = require('mssql');
  var mysql     = require("mysql");
  
  var config = {
      user     : 'sa', 
      password : '******',
      server   : 'serverurl', 
      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); 
  
  
      request.on('recordset',function(col){
          console.time('Time-Taken');
      });
  
      // Emitted for each row 
      request.on('row', function(row) {
  
          syncing(row);
          // console.log('Row Inserted');
  
      });
  
      request.on('error', function(err) {
          console.log(err);
      });
  
      // Emitted for the last one
      request.on('done', function(returnValue) {
          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);
          // else
              // console.log('Added');
  
       });
   };
  </code></pre>