Created
March 2, 2012 10:06
-
-
Save erikdubbelboer/1957486 to your computer and use it in GitHub Desktop.
nodejs db-mysql blocking call example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var mysql = require('db-mysql'); | |
for (var i = 0; i < 4; ++i) { | |
new mysql.Database({ | |
hostname: hostname, | |
user : user, | |
password: password, | |
database: database | |
}).connect(function() { | |
this.query('SELECT SLEEP(10)').execute(function() { | |
console.log('slow query is done'); | |
}); | |
}); | |
} | |
new mysql.Database({ | |
hostname: hostname, | |
user : user, | |
password: password, | |
database: database | |
}).connect(function() { | |
this.query('SELECT 1').execute(function() { | |
console.log('I will only run after the slow selects are done'); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment