Wednesday, May 12, 2021

Node Slip1 B solution

 

Slip 1 b


b.   Create a Node.js file that demonstrate create database student DB and student table (Rno, Sname, Percentage) in MYSQL                                                                                                            [Marks 25]



/* tabledemo.js


var mysql=require('mysql');


var cn=mysql.createConnection({


host:"localhost",


user:"root",


password:"",


database:"student"


});



cn.connect(function(err){


if(err) throw err;


console.log("connected!");


var sql="CREATE TABLE student(rno INT


 AUTO_INCREMENT PRIMARY KEY ,sname


 VARCHAR(20),percentage INT)";


cn.query(sql,function(err,result){


if(err)throw err;


  console.log("Table Created!");


});


})



/* output*/



C:\Users\NEW\nodex>npm install mysql




C:\Users\NEW\nodex>node tabledemo.js


connected!


Table Created!


No comments:

Post a Comment

Slip 10. Write a jQuery code to make first word of each statement to bold.

  Slip 10. Write a jQuery code to make first word of each statement to bold.  <!DOCTYPE html> <html>   <head>     <scri...