Node.js MySQL Insert Record

var mysql = require('mysql');var con = mysql.createConnection({
host: "localhost",
user: "your_username",
password: "your_password",
database: "websolutionstuff"
});
con.connect(function(err) {
if (err) throw err;
console.log("Connected..!!");
var sql = "INSERT INTO users (name, email) VALUES ('websolutionstuff', 'websolutionstuff@gmail.com')";
con.query(sql, function (err, result) {
if (err) throw err;
console.log("Record Inserted Successfully!");
});
});
node db_record_demo.js
Connected..!!
Record Inserted Successfully!

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Websolutionstuff

Websolutionstuff

I am Laravel and PHP Developer. I have also Good Knowledge of JavaScript, jQuery, Bootstrap and REST API.