MySQL Shell can execute SQL, JavaScript or Python code, but only one language can be active at a time. The active mode determines how the executed statements are processed:
If using SQL mode, statements are processed as SQL which means they are sent to the MySQL server for execution.
If using JavaScript mode, statements are processed as JavaScript code.
If using Python mode, statements are processed as Python code.
When running MySQL Shell in interactive mode, activate a
specific language by entering the commands:
\sql, \js,
\py.
When running MySQL Shell in batch mode, activate a specific
language by passing any of these command-line options:
--js,
--py or
--sql. The default mode if none is
specified is JavaScript.
Use MySQL Shell to execute the content of the file
code.sql as SQL.
shell> mysqlsh --sql < code.sql
Use MySQL Shell to execute the content of the file
code.js as JavaScript code.
shell> mysqlsh < code.js
Use MySQL Shell to execute the content of the file
code.py as Python code.
shell> mysqlsh --py < code.py