This article is tagged with:
Sql insert into node js
and mysql
sql insert into node js
var mysql = require('mysql');
var con = mysql.createConnection({
Â
host: "localhost",
 user: "yourusername",
 password: "yourpassword",
 database: "mydb"
});
con.connect(function(err) {
 if (err) throw err;
 console.log("Connected!");
 var sql = "INSERT INTO customers (name, address)
VALUES ('Company Inc', 'Highway 37')";
Â
con.query(sql, function (err, result) {
   if (err) throw err;
   console.log("1 record inserted");
 });
});