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
4
votes
2 answers
Can I store SQL statements in a separate file in node js?
I would like to store all my SQL statements in a separate (.txt maybe?) file. This will make my code look clean and more readable.
Example:
router.get('/', function (req, res, next) {
var sql = // get SQL from a file
connection.query(sql,…

Bravo
- 1,944
- 4
- 29
- 53
4
votes
3 answers
Is building a query using LIKE safe from SQL Injection?
I have an endpoint in my express app that accepts POST data (json). I'd like use the data to query a MySQL database safely. Does escaping and altering my string leave me vulnerable to exploitation?
I need to alter the string that comes in from the…

Mike
- 1,884
- 2
- 24
- 42
4
votes
3 answers
NodeJS MySQL: measure query execution time
I'm on a shared hosting platform and would like to throttle the queries in my app so that if the total execution time exceeds a certain amount over a variable time period then I can make the app cool off and then resume later on.
To do this I would…

Hayko Koryun
- 1,214
- 2
- 12
- 30
4
votes
2 answers
Using node-mysql, how can I NOT escape mysql functions?
I'm trying to use the MySQL function "now()" in an insert statement using the node-mysql module:
var insert = {
username: 'foo',
date_joined: 'now()',
};
connection.query('INSERT INTO users SET ?', [insert],function(err, result){ ... });
As I…

adamdport
- 11,687
- 14
- 69
- 91
4
votes
4 answers
Creating synchronous queries with node-mysql
I'm trying to ensure that one mysql query leads to another and is not completed until all of its children queries are completed. So for example, I start with one select and stream rows and execute subsequent queries from that row result. This is…

4m1r
- 12,234
- 9
- 46
- 58
4
votes
1 answer
Node.JS + MySQL connection pooling required?
With the node-mysql module, there are two connection options - a single connection and a connection pool. What is the best way to set up a connection to a MySQL database, using a single global connection for all requests, or creating a pool of…

Matthew Bradley
- 441
- 3
- 7
4
votes
1 answer
node.js : For each over rows and update asynchronously?
I need to query rows from a database, process some information per row, and then update each row with the result.
This is my example code where the intention is to loop over each row and update the label:
var mysql = require('mysql');
var db =…

Courtney Miles
- 3,756
- 3
- 29
- 47
4
votes
2 answers
Application does not terminate with MySQL pool
I am writing a nodejs application and want to use connection pooling.
However, the following application does not terminate - although I would expect it to terminate after the call to connection.end()
Application works just fine, if I use one…

yas4891
- 4,774
- 3
- 34
- 55
4
votes
1 answer
Decrypt MySQL's AES_ENCRYPT in Node.js
I have a problem with using AES decipher for a buffer object and i hope someone have an idea, what i am doing wrong...
MyExample:
I have a MySQL table with AES_ENCRYPT for username and password...
CREATE TABLE Accounts
(
id INT(4) NOT NULL…

innc
- 41
- 1
- 2
4
votes
1 answer
Performing a MySQL query with node.js and node-mysql
I'm coming from a mostly PHP / MySQL background, and dabbing into node.js to create a blogging system for my own testing and for learning how to do things. The issue I'm having here is that I can't seem to figure out how to do a proper query. I've…

Keith
- 124
- 1
- 9
4
votes
1 answer
Trouble connecting Node-mysql
Im trying to connect to my mysql database with node-mysql. When i try the following code, I get this error:
ERROR: Error: connect ETIMEDOUT
does anyone know whats wrong? The database is up and running btw.
var http =…

Sindresvends
- 180
- 1
- 1
- 10
4
votes
1 answer
Getting error while running node-mysql tutorial
I am running the code in the tutorial part of node-mysql and its giving me error
Code
var MySQLPool = require("mysql-pool").MySQLPool;
var pool = new MySQLPool({
poolSize: 4,
user: 'root',
password: 'root',
database:…

Akhi
- 2,242
- 18
- 24
4
votes
2 answers
Sifting through Node.js, Express and mysql module
I'm trying to work through integrating the express framework for node.js and the mysql module https://npmjs.org/package/mysql. I have a simple application setup (by using the express command line) and I also have a module declared for working with…

tthenne
- 131
- 1
- 8
4
votes
1 answer
node-mysql connection.query() returns undefined
I'm using a node ws server built on einaros/ws.
That server has to send queries to a database. For that i'm using felixge/node-mysql.
When a user connects to the server, it should be checked if the client still exists in the database.
Here is the…

freakimkaefig
- 409
- 5
- 19
4
votes
0 answers
Node-mysql error PROTOCOL_ENQUEUE_A FTER_DESTROY
That is my code:
var mysql = require('mysql');
var client = mysql.createConnection({
host : 'somehost',
port : 'myport',
user : 'username',
password : 'password',
database : 'mydb'
});
//get posts
function…

user1473754
- 41
- 2