SHARE
TWEET

Untitled

a guest Jun 26th, 2019 92 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var mysql = require('mysql');
  2.   var con = mysql.createConnection({
  3.   host: "localhost",
  4.   user: "root",
  5.   password: "root",
  6.   database: "list"
  7.   });
  8.  
  9.   //fs.readFile('list.json', 'utf8', function (err, data)
  10.                     {
  11.   if (err) throw err;
  12.   var obj = JSON.parse(tableData);
  13.   con.connect(function(err) {
  14.         if (err) throw err;
  15.         console.log("Connected!");
  16.         for(var i = 0; i < obj.length; i++) {
  17.               var s_at = obj[i].id;
  18.               var sql = 'INSERT INTO members (scraped_at) VALUES ('+s_at+');
  19.  
  20.               con.query(sql, function (err, result) {
  21.                     if (err) throw err;
  22.                     console.log("x record inserted");
  23.               });
  24.         }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top