Documentation Home
MySQL Shell for VS Code


MySQL Shell for VS Code  /  MySQL Shell Consoles  /  GUI Console Toolbar

Pre-General Availability: 2024-03-18

5.2 GUI Console Toolbar

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:

  1. Click DB Connections under OPEN EDITORS to open or activate the MySQL Shell tab.

  2. 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.

  3. Click the icon, which opens a new shell session in the MySQL Shell Consoles tab.

Note

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.

Console session connections

A new session is given a name automatically in the form of Session X, in which X represents an incremental number starting with 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.

  • host name:port number and 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 see no 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”.

Languages and commands

The active language is shown as one of the following prompts in the editor:

  • js>: JavaScript

  • py>: Python

  • sql>: 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.

Interactive code processing

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.