Menu BAR

FEEL FREE TO ASK ANY PROGRAM and please mention any error if you find it
Showing posts with label sql. Show all posts
Showing posts with label sql. Show all posts

28 Dec 2023

Node js to create the mysql Database

var mysql = require('mysql');
var con = mysql.createConnection({ host: "localhost", user: "admin", password: "admin" });
con.connect(function(err) {
    if (err)
        throw err;
    console.log("Connected!");
    con.query("CREATE DATABASE cprogramcodes", function (err, result) {
         if (err)
            throw err;
        console.log("Database created");
     });
});



15 Nov 2022

Node JS program to connect to SQL table and use WHERE clause

  ## Node JS program to connect to SQL table and use WHERE clause ## 

var mysql = require ('mysql');

// create a connection 
var con = mysql.createConnection({
    host: "localhost",
    user: "admin",
    password: "admin",
    database: "dummy"
});

con.connect(function(err)){
    if (err) throw err;

    con.query("Select * from student where age>15", function (err, result, fields) {
    if (err) throw err;
   
    console.log (" Result is: ", result);
    });
});

14 Nov 2022

Node JS program to connect to sql server

## Node js program to connect to SQL server ##

var express = require ('express');
var app = express();

app.get ('/', function (req,res){
    var sql = require ("mssql");

    // database config
    var config = {
        user: 'admin',
        password: 'admin',
        server: 'localhost',
        database: 'db'
    };

    // Database connectivity
    sql.connect (config, function (err){
        if (err) console.log (err);
        
        //create a request object
        var request = new sql.Request();

        // database query
        request.query (' Select * from student', function (err, record){
        res.send (record);
        });
    });
});

var server = app.listen(3000, function (){
    console.log (' Server running ....');
});

11 Jul 2016

What is SQL

What is SQL?

Full Form : Structured Query Language

Definition : SQL is the standard language for accessing database. It is used to create manage and manipulate the database.