0

例如我有这样的代码:

conn.query('INSERT INTO events_log SET ?', [record]);

如果有错误,库只是显示错误本身,而不是由库进行查询。有可能看到吗?

PS我的意思是查询应该看起来像INSERT INTO events_log SET name = 'va\'lue'没有这个查询的默认错误示例是:

Error: Data too long for column 'ip' at row 1
    at PromiseConnection.query (/Users/node_modules/mysql2/promise.js:92:22)
    at /Users/server.js:195:9
    at processTicksAndRejections (node:internal/process/task_queues:93:5) {
  code: 'ER_DATA_TOO_LONG',
  errno: 1406,
  sqlState: '22001',
  sqlMessage: "Data too long for column 'ip' at row 1"
}
4

1 回答 1

0

添加或debug: true将显示组装的查询:createConnectioncreatePool

mysql.createConnection({debug: true});
于 2021-04-03T11:06:14.377 回答