Advertisement
Guest User

Untitled

a guest
Feb 16th, 2018
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var mysql = require('mysql');
  2.  
  3. var con = mysql.createConnection({
  4.     host: "localhost",
  5.     user: "root",
  6.     password: "",
  7.     database: "example1",
  8.     multipleStatements: true
  9. });
  10.  
  11. function db_call(query) {
  12.     con.query(query, function(err, result) {
  13.         if (err) throw err;
  14.  
  15.         console.log(result);
  16.     })
  17. }
  18.  
  19.  
  20. db_call("create table if not exists a (name VARCHAR(255), address VARCHAR(255))");
  21. db_call("insert into a values('mama', 'lodz')")
  22. db_call("select * from a");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement