Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var mysql = require("mysql"),
- namer = require('color-namer'),
- async = require('async');
- var connection = mysql.createConnection({
- multipleStatements: true,
- host : 'localhost',
- user : 'root',
- password : 'root',
- database : 'xxxx'});
- connection.connect();
- connection.query(
- `SELECT color from sg_fashion_colors limit 10`,
- function(err, results, fields) {
- results.forEach(function(elem){
- var currentHex = elem['color'],
- currentColor = namer(currentHex);
- console.log(currentHex);
- connection.query(
- `INSERT INTO name_color_pat_test (hex, basic) VALUES (?,?);`,
- [currentHex,currentColor['basic'][0]['name']] ,
- function(err,data){
- console.log("insert");
- }
- );
- });
- }
- );
- color
- insert
- color
- insert
- color
- color
- insert
- insert
- connection.query(
- `SELECT color from sg_fashion_colors limit 10`,
- function(err, results, fields) {
- async.eachSeries(results, function (elem, seriesCallback) {
- var currentHex = elem['color'],
- currentColor = namer(currentHex);
- console.log(currentHex);
- connection.query( `INSERT INTO name_color_pat_test (hex, basic) VALUES (?,?);`, // insert the SKU inside a database with their primary color
- [currentHex,currentColor['basic'][0]['name']] ,
- function(err, results, fields) {
- if (err) throw err;
- console.log("insert");
- seriesCallback(null);
- });
- }, function(responsetoendofloop){
- console.log("everything has run");
- });
- }
- );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement