Questions tagged [node-mysql]

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.

699 questions
8
votes
2 answers

Why is MySQL in Node.js so slow?

My Node.js Code is like below CODE1: below var http=require('http'); var MySQL = require('mysql'); mysql = MySQL.createConnection(...) http.createServer(function(req, res){ // the query will take several seconds mysql.query("SELECT…
Garbin
  • 81
  • 1
  • 3
7
votes
2 answers

How to use node-mysql without loads all the rows into the memory?

I'm using NodeJS. I want to do something to 1,000,000 rows without loading all the rows into the memory. (for-each) Before, when I used ASP Classic I did: do while not rec.eof //do something rec.movenext loop In node-mysql I didn't found…
Aminadav Glickshtein
  • 23,232
  • 12
  • 77
  • 117
7
votes
1 answer

Insert array of records into mysql with Node JS

I have a array of data something like var records = [ {Name: '', Id: 1}, {Name: '', Id: 2}, {Name: '', Id: 3}, {Name: '', Id: 4}, {Name: '', Id: 5}, {Name: '',…
7
votes
2 answers

nodejs npm mysql return single row handle

Im using node and npm mysql to do some database work. Is there any way to avoid using the result[0] , if i know Im only going to receive a single row? connection.query({ sql: "SELECT spend FROM `account` WHERE `name` = ? order by date desc limit…
Tyler Evans
  • 567
  • 1
  • 8
  • 25
7
votes
3 answers

Recommended way to change database in existing connecction with node-mysql

I am trying to change database in an existing connection in node. The connection may or may not have database name in createConnection call. Here's the code: var mysql = require('mysql'); connection = mysql.createConnection( { host …
Mukesh Soni
  • 1,119
  • 3
  • 13
  • 23
7
votes
3 answers

node-mysql - when to release connection back into pool

I'm using the node-mysql driver with connection pooling. Releasing the connection back into the pool when there's only one query, is easy: pool.getConnection(function(err, connection) { if (err) { throw err; } query = "SELECT * FROM user…
Philipp Kyeck
  • 18,402
  • 15
  • 86
  • 123
6
votes
2 answers

Node MySQL execute multiple queries the fastest possible

Which is the fastest method gets the query to MYSQL, and then comes back to output: console.log('queries finished', results)" Is there an even better method? Please explain your answer! Thanks! Method 1: var connection =…
user2278120
  • 623
  • 2
  • 9
  • 22
6
votes
2 answers

how does createConnection work with nodeJS in mysql?

What does createConnection do? var connection = mysql.createConnection({ host : 'example.org', user : 'bob', password : 'secret' }); I'm writing an application in nodeJS using mysql module. I have some own modules, for example…
Kiss Koppány
  • 919
  • 5
  • 15
  • 33
6
votes
2 answers

node-mysql connection end or destroy not working

I don't know why mysql.end() or mysql.destroy() are not working as i expect. This is my code. var mysql = require('mysql'); var connection = mysql.createConnection({ host: 'localhost', user: 'root', database: 'db', password:…
6
votes
1 answer

How to return a value from a mysql SELECT query in node.js

I'm still very new to Node.js, and i'm trying to understand how callbacks work. So, here is my problem : I should've put more code : POST : app.post('/register', function(req, res) { //get data from the request var data = { …
redAce
  • 1,558
  • 4
  • 14
  • 24
6
votes
3 answers

Nodejs Cluster with MySQL connections

Looking on advice on clustering of Nodejs and the method of connection to mysql server. Do we open one connection for each child process or just one single connection for all processes? Or do we create a connection pool for all the child processes?…
Hong Zhou
  • 659
  • 1
  • 9
  • 20
6
votes
2 answers

Why is a Mysql query execution in Node JS so much slower than a direct Mysql query execution?

Query: select id, event_time from events where event_time > 1395797406712 and event_time < 1398389406712 order by event_time asc. this query returns ~25k rows (500KB in total size). When I query the above query in Node.js using the node-mysql…
6
votes
5 answers

How to make node.js and mysql work together?

Thanks in advance for your help! I am making a node/express app and I want to use a mysql database. But I can't seem to connect to the database. I know I'm supposed to use the node-mysql module (https://github.com/felixge/node-mysql), but I must be…
6
votes
2 answers

INSERT INTO error with mysql-node

This seems like it should be super easy, and I have been stuck for about two hours now. Four separate people have looked at and not found an obvious problem. So again I turn to the SO community. Real simple - I am just trying to insert data in a…
DrHall
  • 719
  • 1
  • 7
  • 23
6
votes
2 answers

Maximum query length to avoid EPIPE error in node.js

I am using felixge/node-mysql module to interact with MySQL database from node.js. I have met the problem when inserting large amounts of data to database in one INSERT request. Although here there is description of how to add 500,000 records to…
zavg
  • 10,351
  • 4
  • 44
  • 67