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
0
votes
1 answer

How to ensure connection.end() is called when obtaining a database connection from a pool

We are using node-mysql and I'm exposing createPool of mysql where from any file, we can require the database file and obtain a connection like this var db = ("./database"); db(function(err, connection) { //use connection to do stuff } I…
Tolga E
  • 12,188
  • 15
  • 49
  • 61
0
votes
1 answer

Node.js / Socket.io / Mysql to print as JSON

SOLVED: Answer is: socket.on('clients', function(data) { document.write(JSON.stringify(data)); }); I want to get ouput like this (only the part in bold) on the screen as JSON: debug - websocket writing…
Marty Balandis
  • 19
  • 2
  • 10
0
votes
1 answer

module MySQL nodejs

I have a problem with the mysql module this is is my part of code for testing connection : var express = require('express'); var mysql = require('mysql'); var fs = require('fs'); var app = express() , http = require('http') , server =…
2dar
  • 611
  • 2
  • 9
  • 22
0
votes
1 answer

Node.js closing database connections

I inherited some node.js code that I clearly have no idea how it works. The issue I have is it's opening database connections and not closing or reusing them. So at some point I have to kill the node process to release the connections or the…
JSP
  • 547
  • 1
  • 4
  • 18
0
votes
2 answers

Is node-mysql available when using sequelize

I believe that Sequelize utilizes node-mysql in the background? Not sure about this. If it is, I'm wondering if there is any way to use it. Sequelize starts to fall down when you want to do complex multi table queries. But there is no way to run…
CargoMeister
  • 4,199
  • 6
  • 27
  • 44
0
votes
2 answers

unable to remove SQL syntax in UPDATE query

I am updating table when i run this query it give an error: client.query('UPDATE Campaign SET ( Name, StartDate ) VALUES ( "' +req.body.Name+ '" , "' +req.body.StartDate+ '" ) WHERE idCampaign = ' +id , function(err, result) { if(err) { …
ana
  • 653
  • 1
  • 9
  • 20
0
votes
1 answer

Select row for every key in IN statement even if they are equal

Example for my question is follow: I've got an array of id's [ 6230, 206, 4259, 24761, 26736, 219, 281, 281, 516, 495, 10371 ] And I want to setup SELECT query to my database.table like that: SELECT * FROM `database`.`table` WHERE `id` IN (6230,…
0
votes
1 answer

nodejs mysql how to read config parameters

var iniparser = require('iniparser'); var config = iniparser.parseSync('../Config/init/db.ini'); var env = process.env.NODE_ENV || 'dev'; //startup nodejs with e.g: NODE_ENV= node server.js var app =…
Bart
  • 91
  • 3
  • 11
0
votes
1 answer

ENOENT with nodejs mysql and sequelize

I have struggled with this for a few days and cannot figure out what is wrong. I am using: -node.js 0.10.4 -mysql 5.5.29 -node mysql 2.0.0.alpha7 -node sequelize 1.6.0 When I try to execute any queries, I get an error message with ENOENT…
0
votes
1 answer

Express3 JS - Accessing and setting session data in routes

I am trying to access nodejs server session variable within a node-mysql query callback but I don't seem to be able to access or set any of the variables in req.session. connection.connect(); connection.query('SELECT id, firstname, lastname…
Daniel West
  • 1,808
  • 2
  • 24
  • 34
0
votes
1 answer

node-mysql Select Records by Timestamp

I am trying to select a range of records based on a timestamp using NodeJS and node-mysql. My code looks like: sql = "SELECT pressure, temp1, temp2, UNIX_TIMESTAMP(timestamp)*1000 AS unix_timestamp FROM observations WHERE timestamp >= STR_TO_DATE(…
0
votes
1 answer

When I calling method, query returning undefined

node-mysql query returning undefined. Here is my code: Hash.prototype.GetHash = function() { var test; var connection = this.config.CreateConnection(); connection.connect(function(err){ if (err) …
Chipso
  • 1
  • 1
0
votes
1 answer

Sending result set back to client in node.js

I am having an issue getting the result set back to the client using Node.js. I am new to it and using it for a project but I am stuck and not sure why. Here's the situation: I have a webpage, a server, a request handler and a database interface. I…
srbdev
  • 46
  • 6
0
votes
1 answer

node-mysql array escaping is returning only the first element?

I'm using node.js to write an HTTP server for interacting with clients and storing the data sent by them into a mysql database. I'm using node-mysql module to interact with database. Following is a snippet from my code: mysql_conn.query('INSERT INTO…
anni
  • 338
  • 2
  • 12
0
votes
1 answer

Preventing delete where 1 using typeof in node-mysql

I am using node-mysql. I have noticed that when I pass in 1 to a delete query, my whole table gets dropped. This makes sense with my syntax, however I want to protect against accidental drops. Right now, I'm prevent this by making sure you pass in a…
leeway
  • 485
  • 1
  • 3
  • 9