question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to log all SQL query ?

See original GitHub issue
var mysql = require("mysql2");
const chalk = require('chalk');
...
pool.on("connection", function (connection) {
  connection.on("enqueue", function (sequence) {
    if ("Query" === sequence.constructor.name) {
      console.log(chalk.green(`[+] mysql: ${sequence.sql}`));
    }
  });
});
...

I expect to see this on console:

[+] mysql: start transaction; insert into `entities` (`type`) values (3); insert into `companies` set `id` = last_insert_id(), `name` = 'google', `created_by` = 4, `url` = '/google2'; commit;

but nothing happens?

how to make it work on mysql2 ?

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
gsdtcommented, May 15, 2020

thank you for replying me, this question has been asked 3 years ago: https://github.com/sidorares/node-mysql2/issues/610#issuecomment-314933491 did you add this feature?

1reaction
sidorarescommented, May 15, 2020

is it something that worked with mysqljs/mysql and does not work with mysql2?

Before I start helping with “how to make this example work” can you please describe what you see and how it’s not matching what you want to see

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to log ALL queries made by users in SQL Server 2017 ...
I need information (and/or source) if we need MS SQL 2017 Standard or Enterprise in order to ensure that the DB Admin's activities...
Read more >
How to enable sql query logging - Microsoft Q&A
1. Queries are saved in the cache via system representations (sys.dm_exec_query_stats, sys.dm_exec_sql_text, and sys.dm_exec_query_plan) · 2.
Read more >
Log all queries in mysql - Stack Overflow
Enable Query logging on the database. SET global general_log = 1; SET global log_output = 'table'; ; View the log. select * from...
Read more >
General Query Log - MariaDB Knowledge Base
The general query log is a log of every SQL query received from a client, as well as each client connect and disconnect....
Read more >
Logging all queries executed on MSSQL database
This can easily be done by the SQL Server Profiler, which gets shipped with the SQL Studio Express application of Microsoft. However, after ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found