A pure node.js JavaScript Client implementing the MySql protocol. This is about the node package `mysql`, not `node-mysql` which is much less popular.
Questions tagged [node-mysql]
699 questions
18
votes
6 answers
Node.js MySQL Error Handling
I've read several examples for using mysql in node.js and I have questions about the error handling.
Most examples do error handling like this (perhaps for brevity):
app.get('/countries', function(req, res) {
pool.createConnection(function(err,…

Dave
- 1,918
- 1
- 16
- 25
18
votes
1 answer
Difference between using getConnection() and using pool directly in node.js with node-mysql module?
The documentation states that you can either use the pool directly with:
pool.query();
or get a connection manually and then run a query:
pool.getConnection(function(err, connection) {
// Use the connection
connection.query( 'SELECT something…

Miloš Rašić
- 2,229
- 5
- 24
- 43
18
votes
5 answers
Reproduce MySQL error: The server closed the connection (node.js)
I'm trying to reproduce a MySQL error I'm seeing in my node.js app on EC2 with the node mysql library:
Connection lost: The server closed the connection.
I am unable to reproduce the error locally- killing the database is handled just fine by my…

nflacco
- 4,972
- 8
- 45
- 78
17
votes
1 answer
In node.js mysql query, check if no matching found
How can I check if no matching found in mysql (node.js)?
mysql.query("select * from table1 where name = 'abcd'", function(error, result, field) {
if(error) {
exist(error); //No error
} else if(result) {
console.log(result); …

Rejaul
- 831
- 1
- 12
- 35
16
votes
2 answers
How to scale NodeJS linearly on multiple cores?
I am doing a quick performance test for NodeJS vs. Java. The simple use case chosen is querying a single table in MySQL database. The initial results were as follows:
Platform | DB Connections | CPU Usage | Memory Usage |…

Naresh
- 23,937
- 33
- 132
- 204
15
votes
7 answers
Updating multiple rows with node-mysql, NodeJS and Q
I am using node-mysql, node-js, and Q promises.
I have successfully updated, deleted, and inserted single rows using the above. As well as inserted multiple rows in a single statement in my test case scenario.
However, I need to update multiple rows…

Kis Leye
- 161
- 1
- 2
- 3
14
votes
1 answer
How to use nodeJS cluster with mySQL pool cluster?
Quick question
If I make a node cluster application with 4 workers (4 instances of my application), should I use mySQL pool or mysql pool cluster? If I use pool it will create one pool for each application but If I use pool cluster it will create 4…

prieston
- 1,426
- 2
- 18
- 39
14
votes
1 answer
Express JS 'this' undefined after routing with app.get(..)
I have a basic Node JS server which is designed to be used as an API, I've created a log and database module and I've started adding other modules to deal with different request types.
I'm using Express.js and node-mysql
When I visit /v1/group I…

Sam
- 2,771
- 2
- 28
- 41
13
votes
1 answer
Too many Connections on Node-MySQL
I get Error Too many connections when there to much items in a loop with INSERT IGNORE INTO.
function insertCases(cases) {
for(var i in cases) {
var thequery = 'INSERT IGNORE INTO `cases` SET keysused='+cases.keysused+'
…

Scholli
- 419
- 1
- 6
- 15
13
votes
3 answers
How does pool.query() and pool.getGetConnection() differ on connection.release()?
As i can understand every pool.query() will cost a connection and it is automatically release when it ends. based from this comment on github issue. But what about the nested queries performed using…

Shift 'n Tab
- 8,808
- 12
- 73
- 117
13
votes
1 answer
'ER_PARSE_ERROR' on node mysql when inserting multiple values
I'm trying to put in multiple values into database using node-mysql in node.
my source code
engine.files.forEach(function(file) {
torrentpath = file.path.replace(/&/g, "&").replace(/>/g, ">").replace(/

buhbang
- 715
- 1
- 7
- 18
13
votes
5 answers
Node.js cannot find module 'readable-stream'
I am new to node.js and stuck on the following. Any help will be appreciated:
I am running node.js (0.10.28) on ubuntu (12.10). The code I am working on is:
"use strict";
var mysql = require('node-mysql'),
connection = mysql.createConnection({
…

Ronak Hindocha
- 131
- 1
- 1
- 5
12
votes
2 answers
How to input a NodeJS variable into an SQL query
I want to write an SQL query that contains a NodeJS variable. When I do this, it gives me an error of 'undefined'.
I want the SQL query below to recognize the flightNo variable. How can a NodeJS variable be input into an SQL query? Does it need…

GleneaMan
- 167
- 1
- 2
- 13
12
votes
1 answer
how to inject mock testing hapi with Server.inject
I want to test hapi routes with lab, I am using mysql database.
The problem using Server.inject to test the route is that i can't mock the database because I am not calling the file that contains the handler function, so how do I inject mock…

Manan Vaghasiya
- 881
- 1
- 10
- 25
12
votes
4 answers
Inserting Data with Node.js
I 'am trying to insert some data with Node.js. I installed mysql support with npm . I just checked arround some source code, I've wrote following code , I can follow sql output in console.log and SQL output is correct. But It does not affect on…

Onder OZCAN
- 1,556
- 1
- 16
- 36