0
let data = require('knex')({
    client: 'mysql',
    connection: {
        host: 'localhost',
        user: 'root',
        password: 'root',
        database: 'aaaaaa',
        charset: 'utf8'
    },
    pool: {
      min: 1,
      max: 20,
      destroyed: true
    },
})

this is my connection request. how do i find connection id for this?

marko-36
  • 1,309
  • 3
  • 23
  • 38

1 Answers1

0

I have tried different ways that is 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.

Patrick Desjardins
  • 136,852
  • 88
  • 292
  • 341