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

My SQL statement is not comparing unicode emojis properly?

fullEmoji is a property stored in discord.js ParsedEmoji object which should just be a literal emoji ''. The ParsedEmoji is just an interface but I get that from calling parseEmoji() which is a private it's mainly for the discord custom emojis since…
dev-syn
  • 43
  • 6
4
votes
0 answers

How to properly parse mysql-query-results into typescript Objects

I'm currently writing some middleware in typescript (transpiles to JavaScript runs on NodeJS). This middleware uses Typeorm in most cases. But sometimes you want to do crazy stuff with SQL. So i wrote some code that sends raw SQL queries and returns…
SpaceNinjaApe
  • 312
  • 1
  • 13
4
votes
1 answer

node-mysql: Multiple statement queries, ER_PARSE_ERROR

I am trying to run a multiple statement query to a MySQL database. I am using node-mysql and ExpressJS. I have enabled multiple statement queries through setting multipleStatements to true: const connection = mysql.createPool(config.databaseOptions,…
ceno980
  • 2,003
  • 1
  • 19
  • 37
4
votes
2 answers

node-mysql2, AWS.RDS.signer, & connection pooling

I am using the node-mysql2 library in combination with AWS.RDS.signer. I have the following function, which creates a connection pool for reusing connections: const createPool = () => new Promise((resolve, reject) => { signer.getAuthToken({ …
user1031947
  • 6,294
  • 16
  • 55
  • 88
4
votes
3 answers

Sequelize Js - Create new database if its not exists

I am using ( SequelizeJs + NodeJs + Mysql ) in my project Whenever I start the project I want to check the database exists or not and then if it's not there I want to create a new one. I tried this: const mysql = require('mysql2'); let…
Suresh Pattu
  • 6,083
  • 16
  • 59
  • 91
4
votes
1 answer

Why is query execution time so high for Mysql Native driver for node.js? Any alternatives?

Why does same query take around 300 ms more than actual execution time when using Mysql native driver for Nodejs , even with or without using "create pool" options? Please refer highlighted section in below attached screenshot Also for native…
Rizwan Patel
  • 538
  • 2
  • 9
  • 27
4
votes
2 answers

Node-mysql insert query with two values?

This is my current javascript. var connection = mysql.createConnection({ host: 'localhost', user: 'root', password: 'root', database: 'codify', port: '8889' }) connection.connect(); //var querydata = +"'"+data.RegUsername…
AlexDoe
  • 181
  • 1
  • 2
  • 8
4
votes
3 answers

Make MySQL's ORDER BY dynamic in node.js

I want to make the ORDER BY dynamic in mysql query in node.js. But it's not working. I console.log the multiQuery variable and everything looks perfect but when ran it simply doesn't work. This is what I have: var order, …
Murad Elboudy
  • 463
  • 2
  • 11
  • 24
4
votes
1 answer

how to implement clustering in Sequelize?

I have two mysql server both are (MASTER,MASTER). how could we implement clustering in sequelize. if one of sql server has stopped then all request goes to other mysql server without restarting node server.
Vikash Sharma
  • 204
  • 1
  • 8
4
votes
2 answers

'Cannot find module' when import in TypeScript

I have a small problem with importing nodejs modules. For http module this syntax is working well: import * as http from "http"; But when I try to do the same with 'mysql2' node.js module: import * as database from "mysql2"; I gave me an…
Michał Lytek
  • 10,577
  • 3
  • 16
  • 24
4
votes
1 answer

When to use ?? and ? as placeholders in node-mysql for building a query?

I am looking at some examples in node-mysql https://github.com/felixge/node-mysql I am confused over when to use ?? and ? as placeholders in constructing a query. An example is here; var userId = 1; var columns = ['username', 'email']; var query =…
guagay_wk
  • 26,337
  • 54
  • 186
  • 295
4
votes
4 answers

INSERT INTO fails with node-mysql - variable is always NULL

I am using MySql with node.js I have this query and it not works, temp1 in MySQL is alwayls NULL: var queryTemp1 = { tid: '1', temp: temp1, timestamp: myDate }; con.query('INSERT INTO temps SET ?', queryTemp1, function(err,res){ if(err) throw…
piotr
  • 43
  • 5
4
votes
2 answers

How to connect to Cloud SQL instance using nodejs and pem keyfile

I'm trying to connect to Cloud SQL instance from nodejs application using pem file key. var fs = require('fs'); var Sequelize = require('sequelize'); var sequelize = new Sequelize('database', 'root', '', { host: '', dialect: 'mysql', …
Evgeny Timoshenko
  • 3,119
  • 5
  • 33
  • 53
4
votes
2 answers

Trouble Connecting to MySQL via SSH

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…
PositiveGuy
  • 17,621
  • 26
  • 79
  • 138
4
votes
0 answers

How to share a common MySQL pool across node modules?

I have a task where I would need to make multiple queries (> 10) based on the outcome of previous tasks. I created a connection pool using node-mysql module. var pool = mysql.createPool({ connectionLimit: 10, host :…
Rahul Nanwani
  • 1,267
  • 1
  • 10
  • 21