Documentation Home
MySQL Shell 8.0
Related Documentation Download this Manual
PDF (US Ltr) - 0.6Mb
PDF (A4) - 0.6Mb
HTML Download (TGZ) - 125.8Kb
HTML Download (Zip) - 136.9Kb

MySQL Shell 8.0  /  ...  /  Module Search Path Variable in Startup Scripts

9.2.2 Module Search Path Variable in Startup Scripts

The sys.path variable can be customized using the MySQL Shell startup script mysqlshrc.js for JavaScript mode or for Python mode. For more information on the startup scripts and their locations, see Section 9.1, “Working With Startup Scripts”. Using the startup script, you can append module paths directly to the sys.path variable.

Note that each startup script is only used in the relevant language mode, so the module search paths specified in mysqlshrc.js for JavaScript mode are only available in Python mode if they are also listed in

For Python modify the file to append the required paths into the sys.path array:

# Import the sys module
import sys

# Append the additional module paths

For JavaScript modify the mysqlshrc.js file to append the required paths into the sys.path array:

// Append the additional module paths
  sys.path = [...sys.path, '~/custom/js'];
  sys.path = [...sys.path, '~/other/custom/modules'];

A relative path that you append to the sys.path array is resolved relative to the current working directory.

The startup scripts are loaded when you start or restart MySQL Shell in either JavaScript or Python mode, and also the first time you change to the other one of those modes while MySQL Shell is running. After this, MySQL Shell does not search for startup scripts again, so implementing updates to a startup script requires a restart of MySQL Shell if you have already entered the relevant mode. Alternatively, you can modify the sys.path variable at runtime, in which case the require() or import function uses the new search paths immediately.