Connect to MySQL

Connects to a MySQL database.

Command availability: IBM RPA SaaS and IBM RPA on premises

Script syntax

IBM RPA's proprietary script language has a syntax similar to other programming languages. The script syntax defines the command's syntax in the script file. You can work with this syntax in IBM RPA Studio's Script mode.

mysqlConnect --connectionstring(String) (DbConnection)=connection

Limitations

In order for this command to work properly, the MySQL Connector 8.0.28 must be installed. See Installing MySQL Connector for instructions on how to install it.

Input parameter

The following table displays the list of input parameters available in this command. In the table, you can see the parameter name when working in IBM RPA Studio's Script mode and its Designer mode equivalent label.

Designer mode label Script mode name Required Accepted variable types Description
Connection String connectionstring Required Text Connection string 🡥 for the MySQL Database.

A previously configured and accessible MySQL Database must be informed.

Output parameters

Designer mode label Script mode name Accepted variable types Description
Connection connection Database Connection Returns the database connection string.

Example

This example connects to a MySQL database, using the Assert Condition command to verify if the connection was successful. The message "Could not connect to the Database!" is displayed if the connection is empty.

defVar --name dbConnection --type DbConnection
// Connect to the bank via the connection string and store it in the connection variable.
mysqlConnect --connectionstring "server=localhost;User Id=root;database=NameDataBase; password=YourPassword" dbConnection=connection
// Checks if the connection was successful
assert --message "Could not connect to the Database!" --left "${dbConnection}" --operator "Is_Null" --negate