daily pastebin goal
21%
SHARE
TWEET

Untitled

a guest Jun 30th, 2018 30 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var mysql = require("mysql");
  2. var connection = mysql.createConnection({
  3.     host: 'localhost',
  4.     user: 'root',
  5.     password: 'admin',
  6.     database: 'manipal'
  7. });
  8. connection.connect();
  9. /*let createTable = `create table if not exists Books(
  10.     id int primary key auto_increment,
  11.     title varchar(255)not null
  12. )`;
  13. connection.query(createTable,function(err, results, fields){
  14.     if(err){
  15.         console.log(err.message);
  16.     }
  17. });
  18. connection.end(function(err){
  19.     if(err){
  20.         return console.log(err.message);
  21.     }
  22. });
  23. console.log("Books Table created......");*/
  24. /*console.log("Connected......");
  25. var sql = "INSERT INTO Books (title) VALUES('Learn Node JS')";
  26. connection.query(sql,function(err,result){
  27.     if(err) throw err;
  28.     console.log("1 record inserted");
  29. });*/
  30. let sql = `DELETE from Books WHERE id = ?`;
  31. //delete a row with id 1
  32. connection.query(sql,1,(error,results,fields)=> {
  33.     if(error)
  34.     return console.error(error.message);
  35.     console.log('Deleted Row(s):', results.affectedRows);
  36. });
  37. connection.end();
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top