Slip 6 - B) Create a Node.js file that Insert Multiple Records in "student" table, and display the result object on console.

 Solution:

all_cust.js

 var mysql = require('mysql');

var con = mysql.createConnection({

  host: "localhost",

  user: "root",

  password: "root",

  database: "mydb"

});

con.connect(function(err) {

  if (err) throw err;

  con.query("SELECT * FROM customers", function (err, result, fields) {

    if (err) throw err;

    console.log(result);

  });

});


Initiate  :

C:\Users\Your Name>node all_cust.js 

Post a Comment

0 Comments