How does eggjs view the sql statement that has just been executed?

for example, I use the

provided by the egg-mysql framework.
 const results = await this.app.mysql.select("posts", { //  post 
  where: { status: "draft", author: ["author1", "author2"] }, // WHERE 
  columns: ["author", "title"], // 
  orders: [["created_at","desc"], ["id","desc"]], // 
  limit: 10, // 
  offset: 0, // 
});

how can I see the native sql statement executed by this encapsulated statement?

Mar.23,2021

looked at the document and did not find this feature. Can you change the way to deal with it and use mysql log to debug it?

show variables like 'general_log'
set GLOBAL general_log='ON';
SET GLOBAL general_log_file = '/tmp/mysql.log'

turn it off when you are not using it, otherwise it will take up a lot of disk space.


the switch can be set directly in the configuration file

config.mysql = {
    // 
    client: {
      // host
      host: 'x x x x',
      // 
      port: '3306',
      // 
      user: 'x x x x',
      // 
      password: 'x x x x',
      // 
      database: 'x x x',
      debug: false //sql
    },
    //  app 
    app: true,
    //  agent 
    agent: false,
  }

what's the effect of the following?

2-2.png

For the specific implementation of

, you can refer to this article:
Egg, output SQL statement logs?

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b376e9-2b3f8.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b376e9-2b3f8.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?