Questions tagged [node-mysql2]
131 questions
0
votes
1 answer
The correct way to passing connection as parameter to different function in mysql2 nodejs
it's my sample code
// database.js
exports.connection = mysql2.createPool({
host: process.env.DB_HOST,
user: process.env.DB_USERNAME,
password: process.env.DB_PASS,
database: process.env.DB_NAME,
supportBigNumbers:…

Ordinary Person
- 1
- 2
0
votes
1 answer
make mysql connection error in lambda, why?
I wonder difference to main, function
environment
nodejs 14.x
mysql2 2.2.3
I made code,
call pool.getconnection in main, it's fine(success data from db)
but can't get a data from function.
I wonder why this can't get from function
const pool =…

RomeoHY
- 19
- 6
0
votes
0 answers
What can be used instead of classicasync.waterfall in Nodejs?
I am retrieving data from mysql database using Nodejs. Previously, I used to use mysql package but now I am using mysql2 package since it has promises integrated. Now, the question is if I have to run multiple tasks which depend on the output of…

shumana chowdhury
- 1,742
- 2
- 14
- 34
0
votes
0 answers
Why the prepare statement cannot return expected resultset?
Here is my code:
const mysql = require('mysql2');
let dbConfig = require('./config');
dbConfig["multipleStatements"]=true;
dbConfig["insecureAuth"]=true;
const connection = mysql.createConnection(dbConfig);
let…

The KNVB
- 3,588
- 3
- 29
- 54
0
votes
1 answer
Running a MySQL seed file in node js
Summary
I have a schema file I use to set up my database and a seed file I use to populate it with some starter data. I'm running them in MySQL Workbench with no errors. When I try running them using the reset function I made in my SQL wrapper…

JShoe
- 3,186
- 9
- 38
- 61
0
votes
0 answers
mysql2.createPool() & Managed Database Cluster Limits. Should I use mysql2.createConnection() instead?
I've decided to start using mysql2 library lately and created the following example to illustrate what currently works.
A MySQL tempt table is created, a series of queries are run in parallel and then it terminates.
I then found this article MySQL…

suchislife
- 4,251
- 10
- 47
- 78
0
votes
1 answer
Node.js mysql2 module can't connect
I'm having a problem connecting to a database through the mysql2 module for Node.js.
Everything worked, before I deleted some file to do with Git.
After reinstalling everything trying to fix it... still doesn't work.
Node outputs:
Error: connect…

btwon
- 46
- 8
0
votes
1 answer
MYSQL server on EC2 is sometimes refusing to connect
I have hosted a MySQL DB on AWS EC2 instance(t2.micro, ubuntu, free tier). I am able to connect to it and store data. But most of the time, I am unable to connect to it via workbench or my app. But my configurations are correct since I am able to…

Nithur
- 111
- 2
- 10
0
votes
0 answers
Why does my query work in mysql shell but doesn't with node-mysql2?
I have a query:
select
distinct orders.id,
orders.amount,
CONCAT(users.firstName, ' ', users.lastName) as username,
users.email,
users.id as userId,
users.country,
users.phoneNumber,
GROUP_CONCAT(DISTINCT…

mr0b0t0
- 53
- 8
0
votes
0 answers
Nodejs x MySQL2 INSERT a variable
Good day!
Im having a little problem with my nodeJS x MySQL Database.
I connected them together, working fine, im just struggling to insert data, especially inserting a variable such as a project title.
Example:
var titleVariable = "Project1";…

Danny
- 3
- 2
0
votes
1 answer
TypeScript: Create a MySql2 connection object inside a class
I’m new to TypeScript so simple things still trip me up. I successfully created a database connection using the code below which was not in a class:
const mysql = require('mysql2');
let connection = mysql.createConnection({
host: '127.0.0.1',
…

spacedog
- 446
- 3
- 13
0
votes
0 answers
What causes this problem, whereby the query used in phpmyAdmin and in a nodejs app, gets different results?
I have tried this query in phpmyAdmin
SELECT COUNT(*)
FROM meal_participants_user
INNER JOIN user ON meal_participants_user.userId = user.id
ORDER BY meal_participants_user.mealId ASC;
And got in phpMyAdmin the answer 6,
But when I ran this in a…

Geoduin
- 1
0
votes
1 answer
Create table in db with mysql2
I have a question, I want to create a function for auto create table in my database.
I have my models 'MpModel.js' :
//import connection
import db from "../config/database.js";
export const insertMpTab = (id, result) => {
db.query(
…

Arnaud
- 121
- 2
- 6
0
votes
1 answer
How can I define dev & production ENV using express & mysql2?
I found some other similar answers to this, but I was not confident in my ability to comprehend and get it right, so I'm hoping to get a little validation on my approach if it's right, seeing as what i've cobbled together is from a tutorial. I've…

Sharan Balani
- 143
- 1
- 9
0
votes
0 answers
mysql transacation in nodejs project with "npm mysql"
I'm trying to make a transaction(in the node code with mysql npm package) that will select from a table and see if there is a record it will update (UPDATE) otherwise to create a new record (INSERT).
I'm using connection pooling build-in with 'npm…

Anubis
- 1
- 1