20CYS202 - User Interface Design - 3rd Sem - B.E. CSE(CYS) - ASE, CBE
- MySQL 8.0
- Install MySQL
- Configure "username" and "password"
- Create a database
- Node.js
- Install
- NPM
- Run "npm install mysql"
- require includes the npm library "mysql"
- con is the connection variable which creates a connection to mysql instance running in "localhost" with "root" as username and "password" as password to a database "demodb"
- sqlquery variable should have the sql query to be executed
var mysql = require('mysql');
var con = mysql.createConnection({
host: "localhost",
user: "root",
password: "password",
database: "demodb"
});
con.connect(function(err) {
if (err) throw err;
console.log("Connected!");
});
var mysql = require('mysql');
var con = mysql.createConnection({
host: "localhost",
user: "root",
password: "password",
database: "demodb"
});
con.connect(function(err) {
if (err) throw err;
console.log("Connected!");
var sqlquery = "CREATE TABLE CYS (name VARCHAR(255), rollno VARCHAR(255))";
con.query(sqlquery, function (err, result) {
if (err) throw err;
console.log("Table created");
});
});