Friday, May 14, 2021

Node js Slip 30 b Solution Create a Node.js file that demonstrat e create database and Hospital table (hReg, hName, address, contact) in M ySQL

 Slip 30 b

b) Create a Node.js file that demonstrat e create database and Hospital tabl(hReg, hName, address, contact) in M ySQL.



/* Hospital.js*/


var mysql=require('mysql');


var cn=mysql.createConnection({


host:"localhost",


user:"root",


password:"",


database:"mydb"


});



cn.connect(function(err){


      if(err) throw err;

  

      console.log("connected!");


      var sql="CREATE TABLE Hospital(hReg INT


       AUTO_INCREMENT PRIMARY KEY ,hName


        VARCHAR(20),hAddress VARCHAR(20),contact

 

          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 Hospital.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...