Guest User

Untitled

a guest
Nov 16th, 2017
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.46 KB | None | 0 0
  1. npm install mysql
  2.  
  3. var mysql = require('mysql');
  4.  
  5. var con = mysql.createConnection({
  6. host: "localhost",
  7. user: "yourusername",
  8. password: "yourpassword",
  9. database: "mydb"
  10. });
  11.  
  12. con.connect(function(err) {
  13. if (err) throw err;
  14. console.log("Connected!");
  15. var sql = "INSERT INTO customers (name, address) VALUES ('Company Inc', 'Highway 37')";
  16. con.query(sql, function (err, result) {
  17. if (err) throw err;
  18. console.log("1 record inserted");
  19. });
  20. });
Add Comment
Please, Sign In to add comment