Questions tagged [node-mysql2]
131 questions
                    
                    13
                    
            votes
                
                2 answers
            
        Getting Sequelize.js library to work on Amazon Lambda
So I'm trying to run a lambda on amazon and narrowed down the error finally by testing the lambda in amazons testing console.
The error I got is this.
{
  "errorMessage": "Please install mysql2 package manually",
  "errorType": "Error",
 …
         
    
    
        Joseph Astrahan
        
- 8,659
- 12
- 83
- 154
                    12
                    
            votes
                
                5 answers
            
        Encoding not recognized in jest.js
I have a problem testing a project using node-mysql2, react, sequelize and jest. This problem only occurs during testing.
Encoding not recognized: 'cesu8' (searched as: 'cesu8')
    at Object.getCodec…
         
    
    
        Marc
        
- 6,773
- 10
- 44
- 68
                    6
                    
            votes
                
                5 answers
            
        Property 'length' does not exists on type ... OkPacket in mysql2 module
I have code similar to this - very simple just to show the case.
this.getCode = (code: string): Promise => {
        return new Promise((resolve, reject) => {
            pool.query('SELECT * FROM ?? WHERE code = ?', [TABLE,… 
         
    
    
        Seti
        
- 2,169
- 16
- 26
                    5
                    
            votes
                
                1 answer
            
        How to use named parameters in node-mysql2 prepared statements?
The prepared statements document for mysql2 shows positional parameters. While there is some discussion about named parameters, as far as I can tell, they're not documented. If they're supported, how can named parameters be used?
For example, how…
         
    
    
        outis
        
- 75,655
- 22
- 151
- 221
                    5
                    
            votes
                
                1 answer
            
        Bulk insert with mysql2 and NodeJs throws 500
I have a method which I want to bulk insert into mysql. I am using NodeJS and mysql2.
My method:
createWorklog = async ({ sqlArray }) => {
        const sql = `INSERT INTO ${this.tableName}
        (project_id, user_id, date, duration, task,…
         
    
    
        poPaTheGuru
        
- 1,009
- 1
- 13
- 35
                    5
                    
            votes
                
                1 answer
            
        Too many connections Nodejs + mysql2/promise
I am working in a proyect with nodejs + mysql2 and some times I got the error Too many connections.
My connection:
import {createPool, Pool} from 'mysql2/promise';
export async function connect(): Promise < any > {
  const connection: Pool = await…
         
    
    
        Bladimir Medrano Vargas
        
- 608
- 8
- 15
                    5
                    
            votes
                
                1 answer
            
        mysql2 inserting values nodejs
I have this post request 
app.post("/msg", (req, res) => {
  console.log(req.body)
  connection.query('INSERT INTO plans (topic, notes, resources) VALUES 
  (?)', [req.body.topic, req.body.note, req.body.resource],(error, 
  results) => {
     if…
         
    
    
        Salim Abubakar
        
- 53
- 1
- 1
- 3
                    4
                    
            votes
                
                2 answers
            
        mysql2/promise: INSERT statement not valid in transaction query
Thanks for your time. I'm having trouble with creating a transaction query using the mysql2/promise package.
Here's the query:
    await db.execute(`START TRANSACTION`);
    await db.execute(`INSERT INTO user VALUES (?, ?, ?, ?, ?, ?)`,…
         
    
    
        Shockch4rge
        
- 468
- 4
- 10
                    4
                    
            votes
                
                1 answer
            
        nodejs mysql2 async error (intermediate value) is not iterable
my route is like this
import express from 'express'
import mysql from 'mysql2'
import { dbusername } from '../constant/db'
import { dbpassword } from '../constant/db'
import { dbname } from '../constant/db'
import { host } from '../constant/db'
let…
         
    
    
        angry kiwi
        
- 10,730
- 26
- 115
- 161
                    4
                    
            votes
                
                3 answers
            
        How to debug "Jest has detected the following ... open handle potentially keeping Jest from exiting"
I am having further problems with async code in Jest. My previous question (for the same project) was related to running async code in a Jest bootstrap. My new issue relates to running async database calls within the tests. My aim is to connect to…
         
    
    
        halfer
        
- 19,824
- 17
- 99
- 186
                    4
                    
            votes
                
                1 answer
            
        Knex vs. mysql2 based on performance, stability, and ES8+ support
Does anybody have a hands-on experience with both DB-libraries — knex vs. mysql2?
After some googling (e.g. at NPMCompare), I'm still curious to know, based on real experience, what are the pros & contra of both options?
So far, the only real…
         
    
    
        Mike
        
- 14,010
- 29
- 101
- 161
                    4
                    
            votes
                
                3 answers
            
        aws rds proxy throws timeout error from nodejs12.x
I'm getting a connection timeout when I try to connect to mysql rds proxy. I'm followed this tutorial
This is my code
import mysql2 from 'mysql2';
import AWS from 'aws-sdk';
const getConnection = async () => {
    const signer = new…
         
    
    
        Vladimir Venegas
        
- 3,894
- 5
- 25
- 45
                    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
                
                1 answer
            
        What is the proper pattern for bubbling and catching exceptions using async/await?
I am struggling to get my head wrapped around what the proper pattern is for handling errors within nested await/async routines, yet keeping the code clean and simple.  (despite reading countless articles and blogs)
I have a set of functions that…
         
    
    
        user3072517
        
- 513
- 1
- 7
- 21
                    4
                    
            votes
                
                1 answer
            
        mysql2 TypeError: f.ClientHandshake is not a constructor
I'm trying to use mysql2 to connect to an RDS MySQL instance. When I use the package locally, everything works fine. However, when I use it inside an AWS Lambda function, I get this cryptic error:
TypeError: f.ClientHandshake is not a constructor
at…
         
    
    
        BarthesSimpson
        
- 926
- 8
- 21