Documentation Home
MySQL Shell 8.0
Related Documentation Download this Manual
PDF (US Ltr) - 370.8Kb
PDF (A4) - 367.3Kb
HTML Download (TGZ) - 73.9Kb
HTML Download (Zip) - 85.7Kb


MySQL Shell 8.0  /  Reporting with MySQL Shell

Chapter 6 Reporting with MySQL Shell

MySQL Shell enables you to set up and run reports to display live information from a MySQL server, such as status and performance information. MySQL Shell's reporting facility supports both built-in reports and user-defined reports. The reporting facility is available from MySQL Shell 8.0.16. Reports can be created directly at the MySQL Shell interactive prompt, or defined in scripts that are automatically loaded when MySQL Shell starts. A report is a plain JavaScript or Python function that performs operations to generate the desired output. You register the function as a MySQL Shell report through the shell.registerReport method in JavaScript or the shell.register_report method in Python.

For the report to be automatically loaded when MySQL Shell starts, you must store the function and its registration in a script in the init.d folder in the MySQL Shell user configuration path. The file extension is used to determine the language in which MySQL Shell processes the script, so it must be .js or .py as appropriate. Section 6.1, “Creating and Registering User-Defined Reports” has instructions to create and register your reports.

Reports written in any of the supported languages (JavaScript, Python, or SQL) can be run regardless of the active MySQL Shell language. Reports can be run once using the MySQL Shell \show command, or run and then refreshed continuously in a MySQL Shell session using the \watch command. They can also be accessed as API functions using the shell.reports object. Section 6.2, “Running MySQL Shell Reports” explains how to run reports in each of these ways.

In MySQL Shell 8.0.16, the following built-in report is available:

query

Executes the single SQL statement that is provided as an argument. This report has no report-specific options, but the standard options for the \show and \watch commands may be used. For examples, see Section 6.2, “Running MySQL Shell Reports”.