Questions tagged [node-mysql2]

131 questions
1
vote
1 answer

NodeJS mysql2 "Error: No database selected"

I am currently trying to make a little Discord Bot using the mysql2 package for Database Connection. When I set up my DB like this: const con = mysql.createConnection({ host: process.env.DB_HOST, user: process.env.DB_USER, database:…
1
vote
3 answers

CURRENT_TIME Timestamp is incorrect when inserting row in MySQL, I'm using AWS RDS

edit: this was a problem with the mysql library I was using node-mysql2 I am using AWS RDS to host a MySQL database. There is a column in my database with the following definition createdAt TIMESTAMP DEFAULT CURRENT_TIMESTAMP When I inserted a row…
vicg
  • 1,280
  • 14
  • 32
1
vote
1 answer

Node mysql2 async-await try catch

My Question is about handling errors in async-await mysql queries in Nodejs. I'm using mysql promise wrapper to create a connection pool in nodejs. const mysql = require('mysql2/promise'); const pool = mysql.createPool({ host: '192.168.0.1', …
hdk
  • 720
  • 2
  • 9
  • 19
1
vote
1 answer

Nodejs - mysql2 stream connection and remote host

I need to query a mysql database from one server. The mysql database is located on another network. I can only connect to this network from a specific server. I need to create a tunnel from server 1, into server 2 and use this tunnel to connect to…
CharliePrynn
  • 3,034
  • 5
  • 40
  • 68
0
votes
1 answer

i cannot invoke the function in login.html which is specified after the import statement in login.js

This is my code login.html----------------------------------------- RavenL0gin
0
votes
0 answers

Object visibility in express and mysql passport-local

I want to write a comment system in nodejs and I don't understand why the person variable is declared in app.use(multer({dest:"public/uploads/"+${uploadFile}}).single("filedata")); defined as undefined. I save data from mysql to an object on…
Amir
  • 1
  • 2
0
votes
0 answers

Closing database connection for rest service

I am going to develop a REST service with Node Js, using mysql2 module and its pool API. My question is: what is the way to deal with ending connections to databases a rest api service? A single client request may need to do multiple queries to…
Ferex
  • 553
  • 6
  • 22
0
votes
1 answer

Node + MySQL - How to get the raw query with bindings

is it possible to get the raw SQL query with its bindings either prior or after execution to see what's about to, or has just executed? Example: const id = 4 const connection = await fastify.mysql.getConnection() const [rows] = await…
Dally
  • 1,281
  • 4
  • 18
  • 37
0
votes
0 answers

My query is incorrect when trying to update a record in mysql via node but I can't figure out why

This question is asked several times but specifically to this one I'm not sure what I'm doing wrong. Error: UNKNOWN_CODE_PLEASE_REPORT: CONSTRAINT `products.image` failed for `apiDbInk`.`products` Here is my syntax: mysqlCon.query('UPDATE…
FabricioG
  • 3,107
  • 6
  • 35
  • 74
0
votes
1 answer

nodejs query returns at most 25000 rows in mysql2 component

I'm using mysql2 component in typescript My problem is that the query returns a maximum of 25000 rows, even when it should be returning many more This is my code: import { type Pool } from 'mysql2/promise' export interface RecordLayout { success:…
Janka
  • 1,908
  • 5
  • 20
  • 41
0
votes
1 answer

parent: Error: Cannot drop table 'dealers' referenced by a foreign key constraint 'cars_ibfk_1' on table 'cars'

I just cloned my project from my github account. I spin the server and i'm getting triggerUncaughtException(err, true /* fromPromise */); name: 'SequelizeDatabaseError', parent: Error: Cannot drop table 'dealers' referenced by a foreign key…
0
votes
0 answers

mysql2/promise: If one query on transaction fail, will the lock and the connection be released?

When doing transactions using promises in the sql2 npm lib this way: try { const db = await getDatabase(); // this return a connection pool const connection = await db.getConnection(); await connection.beginTransaction(); …
0
votes
0 answers

TypeError MySQL: Bind parameters must not contain undefined

So here is the controller's code which I am using to handle password generation process. There is a table called as passwordrecovery which has the following columns:- id uuid email isActive Code File: db.js const mysql = require("mysql2"); const…
0
votes
0 answers

JS does not allow me to add await before getConnection() from npm mysql2

so basically i cannot add await before pool.getConnection(). It sais 'await' has no effect on the type of this expression. const conn = await pool.getConnection(); pool is of type mysql.createPool({ host: process.env.DB_HOST, user:…
FLTY
  • 35
  • 6
0
votes
0 answers

mysql2 getConnection method is skipped

I have a problem in Nodejs when trying to make a connection with my db via getConnection method. I declared my db variable via require which is a createPool promise(as shown below). when i try to make a connection with that pool via getConnection it…
FLTY
  • 35
  • 6
1 2 3
8 9