MySQL Shell 9.1  /  ...  /  Persisting MySQL Shell Reports

10.1.3 Persisting MySQL Shell Reports

A MySQL Shell report must be saved with a file extension of .js for JavaScript code, or .py for Python code, to match the scripting language used for the report. The file extension is not case-sensitive.

The preferred way to persist a report is by adding it into a MySQL Shell plugin. Plugins and plugin groups are loaded automatically when MySQL Shell starts, and the functions that they define and register are available immediately. In a MySQL Shell plugin, the file containing the initialization script must be named init.js or init.py as appropriate for the language. For instructions to use MySQL Shell plugins, see Section 10.3, “MySQL Shell Plugins”.

As an alternative, scripts containing reports can be stored directly in the init.d folder in the MySQL Shell user configuration path. When MySQL Shell starts, all files found in the init.d folder with a .js or .py file extension are processed automatically and the functions in them are made available. (In this location, the file name does not matter to MySQL Shell.) The default MySQL Shell user configuration path is ~/.mysqlsh/ on Unix and %AppData%\MySQL\mysqlsh\ on Windows. The user configuration path can be overridden on all platforms by defining the environment variable MYSQLSH_USER_CONFIG_HOME.