连接到 MySQL
动词:mysqlConnect
连接到 MySQL 数据库。
语法
mysqlConnect --connectionstring(String) (DbConnection)=connection
输入
| 脚本 | 设计器 | 必需的 | AcceptedTypes | Description |
|---|---|---|---|---|
| --connectionstring | 连接字符串 | 必需的 | 文本 | MySQL 数据库的连接字符串。必须指定先前配置且可访问的 MySQL 数据库。 |
输出
| 脚本 | 设计器 | AcceptedTypes | Description |
|---|---|---|---|
| connection | 连接 | 数据库连接 | 返回数据库连接字符串。 |
示例
此示例连接到 MySQL 数据库,然后使用断言条件命令验证连接是否成功。 如果连接为空,那么将显示消息“Could not connect to the Database!” 。
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
备注
为了使此命令能够正确运行,必须安装 MySQL Connector 8.0.18,并将 dll“MySQL.Data.dll”和“MySQL.Data.EntityFramework.dll”复制到 IBM Robotic Process Automation 文件夹。 以下是执行此操作的逐步指南: