Home > Blockchain >  How to Mysql Data Replicate Using Node Js
How to Mysql Data Replicate Using Node Js

Time:02-04

I want to replicate or send one mysql data to another mysql database using node js how to do this please tell me.

CodePudding user response:

sourceDB.query('SELECT * FROM table', (error, results) => {
  if (error) throw error;

  results.forEach(row => {
    targetDB.query('INSERT INTO table SET ?', row, (error) => {
      if (error) throw error;
    });
  });
});

CodePudding user response:

To copy a record and write to a same database This will copy a record to a new table temp.

CREATE TABLE temp SELECT * from table1
  • Select the record
  • send the record as an endpoint
  • Related