Note that there are some explanatory texts on larger screens.

plurals
  1. POnode-mysql unable to handle multiple queries?
    primarykey
    data
    text
    <p>I am using: node-mysql</p> <p>arrtickers got around 200 values.</p> <p>arrtickers closure pass in values into sym.</p> <p>sym will pass in value to each function (running in async mode, each fn will start running on its own without waiting for the previous fn to complete)</p> <p>problem here is mysql seems unable to handle multiple calls?</p> <pre><code>events.js:48 throw arguments[1]; // Unhandled 'error' event ^ Error: reconnection attempt failed before connection was fully set up at Socket.&lt;anonymous&gt; (/home/ubuntu/node/node_modules/mysql/lib/client.js:67:28) at Socket.emit (events.js:64:17) at TCP.onread (net.js:398:51) arrtickers.forEach(function(value) { var sym= value; (function(sym) { url2= "http://test2.com/quote.ashx?t="+sym+"&amp;ty=c&amp;ta=1&amp;p=d&amp;b=1"; request({ uri:url2 }, function (error, response, body) { jsdom.env({ html: body, scripts: [ jqlib ] }, function (err, window) { var $ = window.jQuery; var data= $('body').html(); //some scrapping var client2 = mysql.createClient({ user: 'root', password: '123', host: '127.0.0.1', port: '3306' }); client2.query('USE testtable'); sql= "update tbla SET a='"+a+"', b='"+b+"', c='"+c+"', d='"+d+"' where ticker='"+sym+"'"; client2.query( sql, function(err, info){ if (err) { throw err; } } ); client2.end(); }); }); })(sym); (function(sym) { url= "http://test3.com/quote.ashx?t="+sym+"&amp;ty=c&amp;ta=1&amp;p=d&amp;b=1"; request({ uri:url3 }, function (error, response, body) { jsdom.env({ html: body, scripts: [ jqlib ] }, function (err, window) { var $ = window.jQuery; var data= $('body').html(); //some scrapping var client3 = mysql.createClient({ user: 'root', password: '123', host: '127.0.0.1', port: '3306' }); client3.query('USE testtable'); sql= "update tbla SET a='"+a+"', b='"+b+"', c='"+c+"', d='"+d+"' where ticker='"+sym+"'"; client3.query( sql, function(err, info){ if (err) { throw err; } } ); client3.end(); }); }); })(sym); (function(sym) { url= "http://test4.com/quote.ashx?t="+sym+"&amp;ty=c&amp;ta=1&amp;p=d&amp;b=1"; request({ uri:url4 }, function (error, response, body) { jsdom.env({ html: body, scripts: [ jqlib ] }, function (err, window) { var $ = window.jQuery; var data= $('body').html(); //some scrapping var client4 = mysql.createClient({ user: 'root', password: '123', host: '127.0.0.1', port: '3306' }); client4.query('USE testtable'); sql= "update tbla SET a='"+a+"', b='"+b+"', c='"+c+"', d='"+d+"' where ticker='"+sym+"'"; client4.query( sql, function(err, info){ if (err) { throw err; } } ); client4.end(); }); }); })(sym); //same function repeat for test5.com, test6.com, test7.com, test8.com, test9.com }); </code></pre> <p>Below is portion of the code from client.js (part of node-mysql) I don't really understand how the whole process get linked together, any idea guys?</p> <pre><code>Client.prototype._connect = function() { this.destroy(); var socket = this._socket = new Socket(); var parser = this._parser = new Parser(); var self = this; socket .on('error', this._connectionErrorHandler()) .on('data', parser.write.bind(parser)) .on('end', function() { if (self.ending) { // @todo destroy()? self.connected = false; self.ending = false; if (self._queue.length) { self._connect(); } return; } if (!self.connected) { this.emit('error', new Error('reconnection attempt failed before connection was fully set up')); return; } self._connect(); }) .connect(this.port, this.host); parser.on('packet', this._handlePacket.bind(this)); }; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload