Questions tagged [mysql2]
The Mysql2 gem is meant to serve the extremely common use-case of connecting, querying and iterating on results.
912
questions
0
votes
1
answer
22
views
ReferenceError only when running tests
I'm getting a boring stacktrace after running my test. I've tried things like fakeTimers, require('iconv-lite')..., etc, from these questions:
Encoding not recognized in jest.js
ReferenceError: You ...
1
vote
0
answers
44
views
Knex: run $ npm install mysql2 --save Invalid or unexpected token
I'm trying to use knex CLI for implementing migrations for my local MySQL database in a Node.js ESM environment.
My knexfile.js file looks like this:
import { DB_NAME, DB_PASSWORD, DB_USER } from &...
0
votes
1
answer
149
views
How to enable polyfill in remix config?
(not a dev, begginer building shopify app w/ remix/node.js and learning to code as I go along)
So whenever i import { CreatPool } from a MySQL2 file/folder, I get the following error in my npm run dev ...
0
votes
0
answers
20
views
Mysql2 error in NextJS13, cant find module Net
I'm trying to acquire information from a mysql database in nextjs13 using the mysql2 dependency, like this:
import mysql from 'mysql2/promise'
export const getData = async(req, res) => {
...
0
votes
0
answers
18
views
DiscordJS mysql connection stops working after bot has been online for several hours
I've had this problem with a discord bot i've made for sometime now. It uses a mysql database and everything works good except for one problem. After the bot has been online for say, 8-10 hours, the ...
0
votes
0
answers
59
views
Mysql Errors when trying to start Rails project with mysql database
I am trying to create a new Ruby Rails project on a Windows system
I have installed Rails v 7.1.1
I then run rails new myRailsProject -d mysql
However, an error occurs:
An error occurred while ...
0
votes
0
answers
28
views
S3Client data retrieval intermittently causes lambda function timeout
The following is a lambda function I'm writing to retrieve a MySQL script from S3 and run it on a specified database.
const { S3Client, GetObjectCommand } = require('@aws-sdk/client-s3');
const mysql =...
0
votes
0
answers
29
views
How do I return table after creating?
How do I return the table after creating it? After inserting in mysql2 in expressjs how do I get the entire created data?
0
votes
2
answers
110
views
umzug unable to import an ES module in node js
I am trying to build a simple app as my personal project using ExpressJS. I am using sequelize ORM for handling database changes. Now I want to rollback a migration and to do so i used the following ...
0
votes
0
answers
27
views
Rails MySql2 Segmentation fault at 0x0000000000000000
getting error while connecting mysql with rails
here is error logs can any one help ?
there are many error logs but grep some which i think important
rails version - 5.2.3
ruby version - 2.5.1p57
...
0
votes
2
answers
131
views
NodeJS large data excel
I have some problems on how to write large data to an excel file in a way that optimizes server memory. I read data from SQL database to the server about more than 1 million rows, this takes a lot of ...
0
votes
1
answer
23
views
Unable to install mysql2 gem in Windows
I have installed Ruby and Rails. When I run a statement:
rails new RailsApp -d mysql
An error has occurred. This is the image. You can click on it to see
I tried install it by many ways, but they are ...
0
votes
2
answers
81
views
mysql2 and close query in nodejs
I am little new in JavaScript so i need to ask cause is different from Java..
I have an application and when starts i connected with mysql2 with this function:
connection.js
const mysql = require('...
-1
votes
1
answer
35
views
uri format connection gets access-denied in mysql
I'm using Node and MySQL2
import mysql2 from 'mysql2'
Following successfully creates connection:
const connection = mysql2.createConnection({
host: 'localhost',
user: 'root',
...
2
votes
1
answer
63
views
How to mock mysql2 `getConnection`
I can't properly mock getConnection method from pool in mysql2 lib. My setup is next:
"ts-mockito": "^2.6.1"
"typescript": "^4.8.4"
"mocha": "^10....
0
votes
0
answers
30
views
Where can i find the typescript type declarations for mysql2?
So, I'm connecting to a MySQL db using the mysql2 module (with pools and async/await) and I handle possible errors with a try catch block, when the catch gets the error typescript says it is unknown
P....
0
votes
0
answers
17
views
How can I select those values efficiently?
the user will provide some filters to get articles from database that need to be filtered out at same time. For example "get up to 10 articles with tag foo or baa, more than 10 likes and contains ...
0
votes
1
answer
49
views
Ruby DBI: Error connecting to MariaDB database
I wanted to follow the first steps of this guide (https://www.tutorialspoint.com/ruby/ruby_database_access.htm) and of course there was a problem.
This is what my code looks like:
#!/usr/bin/ruby -w
...
0
votes
0
answers
40
views
mysql2 on Windows
I'm trying to install redmine 5.0.5 on Window Server2016
using ruby 3.1.4、mysql 5.7.42
When I enter the command "gem install mysql2" in the command prompt.
He return an error "Could not ...
0
votes
0
answers
154
views
MySQL client is not connected (Mysql2:: Error)
I am facing issues with live site with MySQL.
We having 2 servers, the Server 1 went down, then we analysed the logs and found the below error.
MySQL client is not connected (Mysql2:: Error)
And ...
0
votes
0
answers
242
views
My nestjs application uses typeorm and does not release the connection
I found that my nestjs application, after using typeorm to query mysql, the connection was idle but not released
This is the configuration of my nestjs using typeorm version 0.2.45 to connect to mysql:...
3
votes
1
answer
3k
views
rails on M2: dyld[...]: missing symbol called
I upgraded my Rails project from 5 to 6 and now Rails commands throw this error on my M2 mac:
dyld[...]: missing symbol called
It looks like some sort of problem with Node and mysql gem. When I ...
1
vote
0
answers
110
views
Rails health check for database blocked by Mysql2::Error::ConnectionError
In our Rails application we want to add a health check endpoint for things such as the DB, Sidekiq, Redis, and Cache, and this can then be consumed in a variety of ways such as an HTML view, JSON ...
0
votes
0
answers
68
views
Mysql2 - Node js - Object response
When I run a sql query, lets say:
SELECT * FROM USER LIMIT 1
Mysql2 return in [columns,rows]. Instead is there any way, where I get object as result like
{column_name:val}
Eg:
{
Name: Kshitij
Age: 22
...
0
votes
0
answers
77
views
Use existing connection pool with mySQL2 for Node.JS
Does the following code create a new pool every time or will it use an existing pool if one exists?
If it creates a new one each time, what is the code to use an existing connection?
const pool = ...
0
votes
1
answer
42
views
Sequelize + Express: No database selected
Junior developer here.
I am trying to test my api. I'm using Node v18, Express v4 and Sequelize v6 on MySQL.
Here is my config.js
require('dotenv').config();
const { DB_NAME, DB_USERNAME, DB_PASSWORD, ...
0
votes
0
answers
22
views
Trying to use a promisified function to insert values into an inquirer choices field
I set up the promise function via:
const mysql = require('mysql2');
const util = require('util');
require('dotenv').config();
const db = mysql.createConnection(
{
host: 'localhost',
...
2
votes
0
answers
238
views
Adding flags when install gem via `bundle install`
I am trying to install mysql2 gem like below and this works
gem install mysql2 -- --with-cflags=\"-I/usr/local/opt/[email protected]/include\" --with-ldflags=\"-L/usr/local/opt/[email protected]/...
0
votes
0
answers
52
views
Rails 5 and Mysql2 gem issue
I am trying to upgrade a Rails 4 app to Rails 5, looks like all went well and also bundle install succeeds. however when I try to start up the server I see two errors in the below sequence
1. ...
7
votes
3
answers
2k
views
Unable to bundle install 'mysql2' on macOS Ventura caused by 'ld: library not found for -lzlib'
Unable to install mysql2 with bundle install.
I'm asking because some sites and blogs have shown how to solve the problem caused by ssl, zstd, but I couldn't find a solution caused by zlib. Has anyone ...
1
vote
0
answers
125
views
Core dump error while hitting localhost:3000
I'm working with ruby 2.7.5 and rails 6.1.7 on ubuntu 22.04LTS. I've cloned my project and bundle it. Everything is working fine but when I start server by rails s and hit url (localhost:3000), server ...
0
votes
0
answers
94
views
Property 'execute' does not exist on type 'Pool'
I am using mysql2 with TypeScript. I am facing a problem with the Pool interface. Look at the following code -
const pool = mysql.createPool({
host: "localhost",
user: "root",
...
4
votes
1
answer
109
views
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 ...
0
votes
1
answer
480
views
How to get a mysql inner join data (one to many relation) from node js nested array of objects
I am tried to get an array from mysql2 in node js but I am only getting two separate arrays from mysql2 How can I resolve the issue
export const getOrderProducts = async (req, res) => {
const { ...
0
votes
0
answers
14
views
I am facing error with in passport and sequelize module
I am experiencing the following error
Executing (default): SELECT `id`, `nome`, `sobrenome`, `email`, `eAdmin`, `senha`, `createdAt`, `updatedAt` FROM `administrador` AS `administrador` LIMIT 1;
Senha ...
0
votes
0
answers
15
views
Why is Mysql2 queuing statements until the loop is finished?
When executing the following code mysql doesn't start doing anything until the loop is done executing. If i await pool.execute it starts right away and inserts them one at a time, which is expected. ...
0
votes
0
answers
74
views
can't install mysql2 gem on ubuntu 21, ruby 2.7.6
There are a lot of posts about Ubuntu earlier than 21, but 21 cannot find libmysql-dev, libsqlclient-dev, libmariadb-dev, etc.
E: Unable to locate package libmariadb-dev
When trying to install the ...
0
votes
0
answers
2k
views
How do I connect and use data from mysql database in a Vue.js project?
this is my first post. I never had to post anything because I always found a solution searching in the internet or asking friends, but now im really confused so this is my last resource. Don't mind ...
0
votes
1
answer
36
views
Rows from MySQL table is only getting displayed in console and not in POSTMAN?
I'm using MySQL, Nodejs and Serverless-offline plugin here.
For some reason the results from MySQL table are only being displayed in the console of VSCode and not in POSTMAN. What should I do to get ...
0
votes
0
answers
123
views
How can I access properties in rows object from MySQL2 in TypeScript?
I'm currently using Mysql2 package & typescript to retrieve data from MySQL database.
I have accessed the row returned from the execution result by
const data = await resultRetriever....
0
votes
0
answers
201
views
How to connect Sequelize with mysql2 in NextJS. UnExpected error occured
I cant understand this error. I spend a lot of time on this. I am new in Next.Js and using sequelize for mysql. This error has been occured on connection.
I tried to connect with mysql2 with sequelize ...
0
votes
0
answers
20
views
Mysql2 not preparing SQL statement - what am I missing? [duplicate]
I am using mysql2 to connect and execute a simple CREATE DATABASE statement with node:
import {ConnectionOptions, createConnection, createPool, FieldPacket, Pool, RowDataPacket} from "mysql2/...
0
votes
0
answers
170
views
How to share sequelize connection over node js files?
I am trying to make MVC project with node js and sequelize (mysql).
Now I have made the connection to database in the index.js
index.js
const express = require('express')
const msyql = require ('...
0
votes
1
answer
534
views
Node.js mysql2 WHERE id in (?), [ids] returns array with one result
I have a static method getResults(insertIds) inside a class:
static async getResults(insertIds) {
const [result] = await Driver.pool.execute(
"SELECT * FROM test WHERE id in (?)",
[...
0
votes
1
answer
57
views
Mysql2 Ruby: No implicit conversion Array/Hash - INSERT statement
I'm trying to learn mysql2 ruby gem usage and I have encoutered this problem:
no implicit conversion of Array into Hash (TypeError)
When executing the INSERT query:
client.query("CREATE TABLE ...
0
votes
0
answers
94
views
Create new database and table with Ruby and Mysql
I'm switching from Sqlite to Mysql and I can't find much information on how to use mysql2 gem.
Is this the best way to create a new db and then a new table inside it?
require 'mysql2'
client = Mysql2:...
0
votes
0
answers
71
views
How can I test MySql createConnection response using jest?
I just started unit testing and now I find myself in the position where I wish to test if the connection was created successfully or if the response of the function is successful.
(I am aware that ...
0
votes
0
answers
34
views
How to return value from mysql2 query to nodejs function
I've tried to do this a variety of different ways but no matter what I do, the checkGolferExist function is executed async. In the console I see the Ids printed at the top of checkGolferExist, then ...
1
vote
1
answer
4k
views
MySQL connection pools in Node.js (mysql2)
I am struggling to find documentation that describes how so called "Connection Pools" work in Node.js applications, running with the mysql2 package from NPM. I only managed to find some ...
0
votes
0
answers
70
views
How to unit test functions that make calls to database using mysql2?
I am currently starting a new project using Typescript and this is my first time with unit testing.
I have written simple functions to initiate connection and get data from database using mysql2 ...