The GUI console enables you to process MySQL Shell code written in JavaScript, Python, and SQL. JavaScript is the default language available when you initially open a session. You can add multiple console sessions, which are listed in the GUI Console toolbar within the MySQL Shell Consoles tab. Each console session opens in the editor when you select it from the list.
To open the MySQL Shell Consoles tab:
Click
DB Connections
under OPEN EDITORS to open or activate the MySQL Shell tab.-
In the tab, navigate to the Open New Shell Console icon near the Editor list of the toolbar. For the icon's location, see the arrow in the following figure.
Click the icon, which opens a new shell session in the MySQL Shell Consoles tab.
Sessions are not persistent. When you close the MySQL Shell Consoles tab or exit the Visual Studio Code program, each GUI console associated with a session is also closed.
A new session is given a name automatically in the form of
Session
, in
which X
represents
an incremental number starting with X
1
. If you
opened a session from a connection, the name includes the
connection's name (for example, Connection to
Basic
). The number portion of a session name is not
recycled once it has been issued. For example, if you add a
session (Session 1
) and then close it, the
next session you add (without restarting MySQL Shell) is given
the name Session 2
. Renaming a session is not
possible.
By default, sessions added from the MySQL Shell Console browser are not yet connected. If you open a console session from a configured connection (see Connection actions), the established connection is passed to the new session.
The GUI Console toolbar shows the connection status of each session that is active in the editor. A breadcrumb-like indicator under the toolbar displays the following information interactively:
-
not connected
Before establishing a connection to the server, console session activity is limited.
-
andhost name
:port number
schema
After establishing a connection, the host name and port number used to create the session connection are visible (for example,
localhost:3306
). If you specified a schema when you created the session connection, the name appears in the second of the breadcrumb unit. If not, you seeno schema selected
until you select one with the \use command.
For more information, see Section 5.3, “Add a New Shell Session” and Section 5.4, “Connect to MySQL Shell Sessions”.
The active language is shown as one of the following prompts in the editor:
js>
: JavaScriptpy>
: Pythonsql>
: SQL
You can use specific MySQL Shell commands, prefixed with \, which enable you to configure MySQL Shell regardless of the currently selected language. For more information, see MySQL Shell commands.
MySQL Shell provides an interactive code processing mode, where you type code at the MySQL Shell prompt and each entered statement is processed, with the result of the processing printed on screen.
It is possible to specify statements over multiple lines. When
in Python or JavaScript mode, the multiple-line mode is enabled
automatically when a block of statements starts as in function
definitions, if-then statements, for loops, and so on. In SQL
mode, multiple-line mode requires that individual statements be
terminated with the semicolon character (;
).
The subsequently entered statements are cached and shown as
separate tabs (named Result #1
,
Result #2
, and so on) in the result area.
For more information, see Code Processing.