node-mysql

Node-Mysql throwing connection timeout

你离开我真会死。 提交于 2019-12-09 17:38:44
问题 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', password: 'pwd', database: 'mydb', connectionLimit: 15, queueLimit: 30 } var poolCluster = mysql.createPool(config); var queryDB = function(query, cb) { poolCluster.getConnection(function(err, connection) { if(err) { cb(err, null); } else { connection.query(query, function (err, rows) { connection

How to install node-mysql?

断了今生、忘了曾经 提交于 2019-12-08 01:38:23
问题 Im in windows 7 cmd prompt,,, Im trying to instal by: npm install node-mysql Im getting this: C:\Program Files\nodejs>npm install node-mysql npm http GET https://registry.npmjs.org/node-mysql npm http 404 https://registry.npmjs.org/node-mysql npm ERR! 404 'node-mysql' is not in the npm registry. npm ERR! 404 You should bug the author to publish it npm ERR! 404 npm ERR! 404 Maybe try 'npm search mysql' npm ERR! 404 npm ERR! 404 Note that you can also install from a npm ERR! 404 tarball, folder

NodeJS MySQL: measure query execution time

浪尽此生 提交于 2019-12-07 17:42:22
问题 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 like to find out how long each of my queries take in real time and manage it within the app and not by profiling it externally. I've seen examples in PHP where the time is recorded before and after the query (even phpMyAdmin does this), but this

insert multiple rows into mysql through node.js

五迷三道 提交于 2019-12-07 13:36:44
问题 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+' SET ?', data, function(err, result) { if (err) throw err; else { console.log('successfully added to DB'); connection.release(); } }); }); } which fails. Is there a way for me to have a bulk insertion and call a function when all insertion finishes? Regards

Trouble connecting Node-mysql

别等时光非礼了梦想. 提交于 2019-12-07 10:26:38
问题 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 = require('http'); http.createServer(function (req, res) { res.writeHead(200, {'Content-Type': 'text/plain'}); res.end('Hello World\n'); }).listen(1337, '127.0.0.1'); console.log('Server running at http://127.0.0.1:1337/'); var mysql = require('mysql'); var connection = mysql

Error connecting to Amazon RDS (MySQL) from node-mysql

落花浮王杯 提交于 2019-12-06 10:41:36
问题 I am trying to connect to my Amazon RDS (MySQL) instance from a nodejs code hosted in Lambda using the "felixge/node-mysql" package. I need help to find out what I am doing wrong. I am getting "connect ETIMEDOUT" error. My code is hosted in Lambda and both Lamda and RDS are of the same account and region. I have also attached the RDSFullAccess Policy to the IAM role. RDS instance is also accessible from all IPs(no whitelist/blacklisted IPs). At the same time, I am able to connect from my

node.js and mysql connection pool does not export

匆匆过客 提交于 2019-12-06 08:33:38
问题 I am unable to export a pool connection in node.js. What I want is to get the connection from the pool from the db.js and use it and then release it after using it. db.js var mySQL = require('mysql'); var pool = mySQL.createPool({ host: config.host, user: config.user, password: config.password, database: config.database }); var getConnection = function() { pool.getConnection(function(err, connection) { if(err) throw err; return connection; }); }; module.exports.pool = getConnection; query.js

how does createConnection work with nodeJS in mysql?

徘徊边缘 提交于 2019-12-06 04:37:07
问题 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 authentication , which definetely needs DB connection. Question is: if I have multiple modules where I use this method to create the connection, will it create a new connection for me everytime or use the first one? If creates, it creates the first time it loads my own

Can't connect to localhost database from node.js server

若如初见. 提交于 2019-12-06 02:17:55
Been having a lot of trouble trying to connect to to my localhost database. I've tried using the mysql and mysql-simple node modules but in both cases I just can't get it to connect. Here's what I used with the 'mysql' module: var mysql = require('mysql'); var connection = mysql.createConnection({ host : 'localhost', port : '8000', user : 'uber', password : 'pass', }); connection.connect(function(err) { if (err) throw err; console.log('Connection Successful'); }); connection.query('USE someDB', function(err) { if (err) throw err; console.log('Query Successful'); }); And here' what I used with

Trouble Connecting to MySQL via SSH

痴心易碎 提交于 2019-12-06 01:05:06
I am running a node Express website on my OS X machine locally. I need to ssh to a remote mysql database so I can start writing queries against it. Now I'm able to ssh to our remote server (running the mysql database) in the cloud when I do it via my OS X Yosemite terminal. But I haven't been successful trying to do it in code using the node-mysql and tunnel-ssh node middleware. My code runs but doesn't really error out except for my GET when debugging my express app in Webstorm. Some facts : I'm able to SSH into mySQL from OS X using this command: ssh -L 3306:127.0.0.1:3306 ourCloudServerName