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
11
votes
1 answer
Retrieve Data from Just-Inserted Row (MySql and Node.js)
if I have a query like the following:
var queryString = "INSERT INTO pid SET title = '" + randomTitle + "', poc = '" + random + "';"
connection.query(queryString, function(err, rows, fields) {
...(do something here)
});
, is there a way I can…

Tim Clotworthy
- 179
- 2
- 6
10
votes
3 answers
Perform two or more queries in one request using node-mysql and ExpressJS
tl;dr: What is the correct way to handle two or more asynchronous queries to a MySQL database using node-mysql with ExpressJS?
I am using ExpressJS with node-mysql to perform two separate, unrelated database queries on a MySQL database. Since the…

TDN169
- 1,397
- 2
- 13
- 31
10
votes
4 answers
NodeJS / Express - Make Available MySQL Connection Object in Router File
I have the following in my app.js file:
var mysql = require('mysql');
var connection = mysql.createConnection({
host: 'localhost',
port: 3306,
user: 'user',
password: 'password',
database:…

Lloyd Banks
- 35,740
- 58
- 156
- 248
10
votes
1 answer
Node.js and mysql Callback : query in query callback
All I want to do is insert some data if my database doesn't have that, so I put Insert SQL into my callback function of my Select SQL, but I got error like this:
{ [Error: Cannot enqueue Query after invoking quit.] code:…

Arvin
- 405
- 1
- 8
- 18
9
votes
3 answers
Node-Mysql throwing connection timeout
My node.js app gives 5xx due to connection timeouts at random times. Here's how I connect and query:
var mysql = require('mysql');
var config = {
host: '172.10.1.1',
port: 3306,
user: 'user',
…

Haywire
- 858
- 3
- 14
- 30
9
votes
2 answers
Node-MySQL - Escaping in Query() Method vs Mysql.Escape() / Mysql.EscapeId()
I am currently using the node-mysql library to connect my application to a MySQL instance. After reading some other StackOverflow questions and articles I found, it sounds like node-mysql automatically escapes unsafe characters every time the…

Lloyd Banks
- 35,740
- 58
- 156
- 248
9
votes
6 answers
SELECT WHERE IN in node-mysql
Does anyone know how to use SELECT WHERE IN in node-mysql?
I've tried the code below, but I get the following error message:
'You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax…

Takehiro Adachi
- 954
- 1
- 9
- 22
8
votes
7 answers
Node JS Inserting array of objects to mysql database when using transactions
Am using node-mysql to add records to a database but am facing a challenge when the records to be inserted are an array of objects and I need the operation to be a transaction. I have simplified my problem by creating a test project to better…

Dennis Wanyonyi
- 368
- 1
- 5
- 18
8
votes
2 answers
node-mysql Rethrow non-MySQL errors
I just switched my node api over to use node-mysql. It keeps suppressing my errors/stack traces making development and debugging a nightmare. For example, I am writing a new feature and I get this error:…

Jeremy
- 1,717
- 5
- 30
- 49
8
votes
2 answers
Close connection MySQL Node.js
I'm developing a Node application with ExpressJS and MySQL. I'm working with this module https://github.com/felixge/node-mysql/ and I'm learning its use yet.
I get troubles about how to close connections properly.
This is what I…

Ulyarez
- 155
- 1
- 2
- 10
8
votes
1 answer
Best Way to Use OOP in Express REST API?
I'm going all in and doing a project using only node. It's been a lot of fun, but sometimes I get a little lost in it and I want to try to gain understanding as I get confused so I build it correctly and don't get too overwhelmed. Anyway, here's the…

Z2VvZ3Vp
- 7,033
- 6
- 21
- 35
8
votes
1 answer
node.js, express - executing mysql queries one after another within loops in a synchronous way
In my node.js, express app, I am making an ajax call with the superagent middleware. The call fetches database data in a complex array using the node-mysql middleware through quite a few database queries.
Before pasting the code, I am trying to…

Istiaque Ahmed
- 6,072
- 24
- 75
- 141
8
votes
3 answers
insert multiple rows into mysql through node.js
I want to insert multiple rows into mysql thru node.js mysql module. The data I have is
var data = [{'test':'test1'},{'test':'test2'}];
I am using pool
pool.getConnection(function(err, connection) {
connection.query('INSERT INTO '+TABLE+'…

Hammer
- 8,538
- 12
- 44
- 75
8
votes
7 answers
node-mysql error: connect ECONNREFUSED
I'm trying to setup a remote connection between my database server and a client node app using node-mysql.
When I try to connect to the remote db, I get this error:
node.js:201
throw e; // process.nextTick error, or 'error' event on first tick
…

Skoua
- 3,373
- 3
- 38
- 51
8
votes
1 answer
How to make login form in node.js using mysql database
I am new in node.js and i want to make a login page using express and mysql database,Please share with me your idea with example.

Rohit Dhiman
- 125
- 1
- 1
- 7