Questions tagged [node-mysql2]

131 questions
0
votes
1 answer

increment counter column in one table if ip address exists in another table MYSQL

I have a viewCount column in table_1. Every time a user with a new ip address visits the page I increment viewCount column in by 1. This is to keep record of how many people have visited the page. In table table_2, I keep the ip address of the users…
0
votes
1 answer

ER_TRUNCATED_WRONG_VALUE: Incorrect date value: '0' - NodeJS with correct DATE value

I am trying to insert into a standard ISO date into MySQL database from nodejs and getting the following error: ER_TRUNCATED_WRONG_VALUE: Incorrect date value: '0' for column 'lastmod' at row 1 All of the other questions on StackOverflow it seemed…
fotoflo
  • 821
  • 1
  • 9
  • 21
0
votes
1 answer

node.js mysql2 how to save from select in var

have mysql database with some fields con.query( 'SELECT rk_individual_id FROM `valid_users` WHERE `login` = ? ', ["ya010156gmv"], function(err,result){ if (err) { console.log('db fetch…
0
votes
0 answers

How to connect to remote mysql server with nodejs?

i need to connect to remote mysql database from my nodejs appliacation. Below is my code. const mysqlssh = require('mysql-ssh'); mysqlssh.connect( { host: '572.168.0.68', //ssh login ip user: 'root', // ssh…
Jagadeesh
  • 1,967
  • 8
  • 24
  • 47
0
votes
1 answer

Is there any Better way to insert a row into MYSQL database in node.js?

So i am going with mysql2 driver to use Mysql with node. Let's say i have 25 to 30 maybe more fields in a row, would i have to manually write every column after extracting it from body. My current approach is as below, here's the complete controller…
Sumair
  • 103
  • 1
  • 2
  • 8
0
votes
1 answer

User based set time_zone mysql2 nodejs

I'm storing sales date as UTC in TIMESTAMP column in mysql table. users around the world need to show sales in their settings based timezone how to set timezone for each user request using mysql2 npm package?
jafar
  • 15
  • 4
0
votes
1 answer

How to set limit for joined mysql table?

I'm trying to combine data from 3 tables with below query SELECT `media_category`.id as cat_id, `media_category`.category_name as cat_name, `video`.`id` as vid_id, `video`.`name` as vid_name, `screenshots`.name as…
Hashan Sachintha
  • 133
  • 1
  • 10
0
votes
2 answers

Multiple Statements in mysql2 - nodejs

I'm using mysql2 in my nodejs project, in mysql library i used Multiple Statements for update my database and that works great, but for some reason in mysql2 it doesn't work, i googled it a lot and didn't found any solution, does mysql2 not support…
0
votes
0 answers

Fetch millions of records using mysql2 package in node js

My MySQL database has 2 million records in my one table. i am developing an api using node.js to fetch records from the table. I am using mysql2 package to connect to the database. following is my code to fetch all records from table. var query1 =…
Rahul Lad
  • 337
  • 1
  • 5
  • 15
0
votes
1 answer

pass argument to mysql connection string

Below is my code (under file db.js) function connection() { try { const mysql = require('mysql2'); const pool = mysql.createPool({ host: "mydb.abcd1234.ap-southeast-1.rds.amazonaws.com", database: "mydatabase", user:…
imin
  • 4,504
  • 13
  • 56
  • 103
0
votes
1 answer

RDS Serverless and MySQL connection pool issue

I recently tried out an RDS serverless with my node-js based chat engine, almost everything works fine except one problem. I create my MySQL connection pools as below, host : config.database.host_read, user: config.database.user, …
mahen3d
  • 7,047
  • 13
  • 51
  • 103
0
votes
1 answer

MySQL2 Library NodeJS - Update Fails without error & RowsAffected on async call

The way to get AffectedRows when non-Async is shown here: https://github.com/mysqljs/mysql/issues/363 My Code below - none of the console.logs after the update display in the console, certain columns are not being updated in the database, and no…
NealWalters
  • 17,197
  • 42
  • 141
  • 251
0
votes
3 answers

MySQL NodeJs - Proper way to get rows.each to work

When I look for simple examples, everybody's style seems quite different. I'm tried 2 different styles, and got 2 different issues. In the code below, I have identified the source of the code and the error it gets in comments. I comment out or…
NealWalters
  • 17,197
  • 42
  • 141
  • 251
0
votes
1 answer

Migrating callbacks to Async

I'm struggling with migrating a HAPI function that verifies a JWT token and then makes a database call using the decoded credentials. The problem is that jwt.verify uses a callback, but Hapi and Hapi.MySQL2 have both been updated to use async…
Dan Kelly
  • 2,634
  • 5
  • 41
  • 61
0
votes
2 answers

How to correctly make multiple MySQL calls in a single request with Node.js, Express.js, MySQL2, and Promises

Looking at the correct/best/better way to use AWAIT with MySQL2 in a Node.js/Express.js app when I need to run multiple queries in a single request. Early on in my app I create a Promise Pool from my Database config const promisePool =…
Andy Jarrett
  • 863
  • 2
  • 9
  • 26
1 2 3
8
9