Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Created by dimbo on 02.05.2017.
- */
- var mysql = require("mysql");
- var readline = require('readline')
- // First you need to create a connection to the db
- var connection = mysql.createConnection({
- host: "localhost",
- port: "3306",
- user: "root",
- password: "DIMbot%5452332",
- database : 'userlogin'
- });
- connection.connect(function (err) {
- if(err){
- console.log('Eror connecting to database');
- }
- });
- var r1=readline.createInterface({
- input:process.stdin,
- output:process.stdout
- });
- r1.question('Enter User id', (id)=>{
- var user = {userId:id};
- r1.question('Enter User name', (name)=>{
- var user = {userName:name, userId:id};
- connection.query('INSERT INTO users SET ?', user, function(err,res) {
- if(err) throw err
- });
- });
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement