Documentation Home
MySQL 5.7 Reference Manual
Related Documentation Download this Manual
PDF (US Ltr) - 37.4Mb
PDF (A4) - 37.4Mb
PDF (RPM) - 37.0Mb
EPUB - 10.6Mb
HTML Download (TGZ) - 10.3Mb
HTML Download (Zip) - 10.4Mb
HTML Download (RPM) - 9.0Mb
Eclipse Doc Plugin (TGZ) - 11.2Mb
Eclipse Doc Plugin (Zip) - 13.4Mb
Man Pages (TGZ) - 204.7Kb
Man Pages (Zip) - 311.8Kb
Info (Gzip) - 3.4Mb
Info (Zip) - 3.4Mb
Excerpts from this Manual

3.8.5.2 Scripting Stored Sessions

A built in object is available to manage and use the stored connections through JavaScript or Python: shell.storedSessions

3.8.5.2.1 Adding a Connection

To add a new connection use:

shell.storedSessions.add(name, connectionData[, override])
  • name : Mandatory parameter, it is the session name that identifies the connection data. This must be a valid identifier.

  • connectionData : Mandatory parameter, it contains the connection information and can be either a string in URI format or a connection data map containing any of the following values:

    • host

    • port

    • dbUser

    • dbPassword

    • schema

    • ssl_ca

    • ssl_cert

    • ssl_key

      To store the connection data at least the host and dbUser parameter should be specified, the rest are optional.

  • override : Optional boolean parameter, used to indicate the desired behavior in case there is a stored connection data associated to the same name. Default value is false.

    • If override is false and connection data with the same name already exists, an error is generated.

    • In the same scenario, if the new connection data overrides the previous data and an error is not generated.

3.8.5.2.2 Updating a Stored Connection

To update the connection data for a specific session name use:

shell.storedSessions.update(name, connectionData)
  • name : Mandatory parameter, it is the name that will identify the connection data. Note that this must be a valid identifier.

  • connectionData : Mandatory parameter, it contains the connection data and can be either a string in URI format or a connection data map.

3.8.5.2.3 Removing a Stored Connection

To remove a connection use:

shell.storedSessions.remove(name)
  • name : Mandatory parameter, identifies the connection data to be removed.

3.8.5.2.4 Listing the Stored Connections

To list the stored connections use:

shell.storedSessions
3.8.5.2.5 Using a Stored Connection

When the shell.storedSessions object is initialized, it loads the stored session data and creates a property to access them as shell.storedSessions.name

var session = mysqlx.getSession(shell.storedSessions.name)

When used this way, if the connection data has no password it is not requested. It is the developers responsibility to provide the password either using the stored session data or as an additional parameter as follows:

var session = mysqlx.getSession(shell.storedSessions.name, password)

User Comments
Sign Up Login You must be logged in to post a comment.