node.js - 如何在建立连接时使用 knex npm 包获取 MySQL connectionId?
问题描述
let data = require('knex')({
client: 'mysql',
connection: {
host: 'localhost',
user: 'root',
password: 'root',
database: 'aaaaaa',
charset: 'utf8'
},
pool: {
min: 1,
max: 20,
destroyed: true
},
})
这是我的连接请求。我如何找到这个的连接ID?
解决方案
I have tried different ways.it's working fine.
let data = require("knex")({
client: "mysql",
connection: {
host: "localhost",
user: "root",
password: "root",
database: "aaa",
charset: "utf8",
},
pool: { min: 1, max: 20 },
});
let result = await data.raw("SELECT CONNECTION_ID() as connectionId");
console.log("HERE IS THE PRIMARY CONNECTION ID", result[0][0]["connectionId"]);
if anyone having a different way please share. Without doing any query operation.
推荐阅读
- reactjs - 如何使用 antd 网格设计具有行和列跨度的表单?
- jestjs - 返回结果后调用的 jest.spyOn 函数
- rest - 将特殊字符作为 URI 参数的一部分传递
- facebook - 什么是 Facebook 开发者控制台上的 Facebook 网页游戏
- r - 打印 R 中模型生成的所有值
- ios - 如何为两个不同的表格视图使用相同的表格视图单元格?
- mongodb - 如何使用 compose transporter 将 mongo DB 文档拆分为多个文档
- android - 输入调度超时(等待发送非键事件,因为触摸的窗口尚未完成对某些输入事件的处理
- python - python + pandas可以用来关联字符串列表吗?
- python - Django Heroku Debug = False,静态文件导致内部服务器错误