Error: Incorrect arguments to mysqld_stmt_execute when trying to SET with .execute()
See original GitHub issueHi everyone, Trying to wrap my head around async here. I’ve extracted my connection code using the following :
const mysql = require('mysql2/promise');
const config = require("./config");
/*
* @sqlConnection
* Creates the connection, makes the query and close it to avoid concurrency conflicts.
*/
var sqlConnection = async function sqlConnection(sql, values, next) {
// It means that the values hasnt been passed
if (arguments.length === 2) {
next = values;
values = null;
}
const connection = await mysql.createConnection(config.db);
/*connection.connect(function(err) {
if (err !== null) {
console.log("[MYSQL] Error connecting to mysql:" + err+'\n');
}
});*/
const [rows, fields] = await connection.execute(sql, values, function(err) {
if (err) {
throw err;
}
// Execute the callback
next.apply(this, arguments);
});
}
module.exports = sqlConnection;
I’m trying to insert into my database using the following :
var db_results = db_connection('INSERT INTO organisation (name, social, address, country, zip) VALUES (?,?,?,?,?)', {name: input.name, social: input.social, address: input.address, country: input.country, zip: input.zip}, function (error, rows) { console.log(query.sql); });
I’ve tried quite a few things, using SET, changing the number of ?, naming or not the query, yet I keep getting
Error: Incorrect arguments to mysqld_stmt_execute
Any insight ?
Issue Analytics
- State:
- Created 5 years ago
- Comments:7 (5 by maintainers)
Top Results From Across the Web
Error: Incorrect arguments to mysqld_stmt_execute
const [result] = await mysql.execute( `SELECT * FROM user LIMIT ${pageNumber},20;` );. and, if the variable is a string, put ' ' around...
Read more >Incorrect arguments to mysqld_stmt_execute (MySQL 8.0.22)
Hi, love this library! ... Now this error is wrapped by my own logic, but the cause I think it quite clear: Incorrect...
Read more >Error 1210 - “Incorrect arguments to mysqld_stmt_execute
We suspect the query failure happens when we create a row in the table containing a blob column and if the blob is...
Read more >Python MySQL Execute Parameterized Query using Prepared ...
execute() function to run a parameterized query. SQL query; A tuple of parameter values. In our case, we need to pass two Python...
Read more >Cloud SQL for MySQL error messages
In this case, the request is using either the wrong argument or an ... The error has also been seen when trying to...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
re main question: you must use one simple type value per ?:
I think this is unrelated to main question, but why are you using await and callback together?