JavaScript MySQL 插入批量准备语句时出错

JavaScript MySQL Error while inserting bulk prepared statements

我有问题。我正在尝试使用准备好的批量语句在我的数据库中插入几百个对象。我要插入的 table 如下:

然后我有以下代码:

static save() {
    data = [[1, '', '', 0, 0, 0, 0, 0], [2, '', '', 0, 0, 0, 0, 0], [3, '', '', 0, 0, 0, 0, 0], [4, '', '', 0, 0, 0, 0, 0]];
    let sql = "INSERT INTO Candlestick (openTime, market, `interval`, open, high, low, close, volume) VALUES (?, ?, ?, ?, ?, ?, ?, ?);";
    return db.execute(sql, [data]);
}

但这会导致以下输出:

Error: Incorrect arguments to mysqld_stmt_execute
    at PromisePool.execute (C:\Users\Alexander\Projects\API\node_modules\mysql2\promise.js:359:22)
    at Function.save (C:\Users\Alexander\Projects\API\src\api\v1\models\Candlestick.js:18:19)
    at C:\Users\Alexander\Projects\API\src\api\v1\controllers\candlestickController.js:28:29
    at processTicksAndRejections (node:internal/process/task_queues:96:5) {
  code: 'ER_WRONG_ARGUMENTS',
  errno: 1210,
  sql: 'INSERT INTO Candlestick (openTime, market, `interval`, open, high, low, close, volume) VALUES (?, ?, ?, ?, ?, ?, ?, ?);',

当我复制查询并手动将变量设置为:

INSERT INTO Candlestick (openTime, market, `interval`, open, high, low, close, volume) VALUES (1, '', '', 0, 0, 0, 0, 0);

查询确实在 phpmyadmin 中执行:

谁能告诉我我错过了什么...

我正在使用:
mysql2 - ^2.3.3
mariadb - 10.3.34

要解决此问题,我必须更改查询:

let sql = "INSERT INTO Candlestick (openTime, market, `interval`, open, high, low, close, volume) VALUES (?, ?, ?, ?, ?, ?, ?, ?);";

至:

let sql = "INSERT INTO Candlestick (openTime, market, `interval`, open, high, low, close, volume) VALUES ?;";

因为[数据]中的每个条目都代表:(1, '', '', 0, 0, 0, 0, 0) 这样每次都填满。此外,我将 db.execute 更改为 db.query,因此将在客户端准备查询。这样做的好处是,当查询出错时,可以在控制台看到准备好的查询结果。