连接到 SQLite
动词:sqliteConnect
连接到 SQLite 数据库。
语法
sqliteConnect [--createNew(Boolean)] --connectionString(String) [--sql(String)] [--path(String)] [--password(String)] (DbConnection)=connection (String)=connectionString (String)=path (Boolean)=success
输入
| 脚本 | 设计器 | 必需的 | AcceptedTypes | Description |
|---|---|---|---|---|
| --createNew | 新建 | 可选 | BOOLEAN | 启用后,将创建新的 SQLite 数据库。 |
| --connectionString | 连接字符串 | 仅当“新建”为 False 时 | 文本 | 连接到 SQLite 数据库时使用的连接字符串。 |
| -- SQL | SQL 命令 | 可选 | 文本 | 用于创建 SQLite 数据库的 SQLite 命令。 |
| --path | 路径 | 可选 | 文本 | 创建 SQLite 文件的完整路径。 |
| --密码 | 密码 | 可选 | 文本 | 用于访问要创建的数据库的密码。 |
输出
| 脚本 | 设计器 | AcceptedTypes | Description |
|---|---|---|---|
| connection | 连接 | 数据库连接 | 连接到 SQLite 数据库。 |
| connectionString | 连接字符串 | 文本 | 用于访问 SQLite 数据库的连接字符串。 |
| 路径 | 路径 | 文本 | 仅当 IBM RPA Studio 自己创建数据库时,才会返回的 SQLite 数据库文件的完整路径。 |
| 成功 | 成功 | BOOLEAN | 如果创建了与 SQLite 数据库的连接,那么返回“True”;否则,返回“False”。 |
示例
此示例连接到 SQLite 数据库,然后使用断言条件命令验证连接是否成功。 如果连接为空,那么将显示消息“Could not connect to the Database!” 。
defVar --name dbConnection --type DbConnection
defVar --name connectionString --type String
defVar --name dbPath --type String
defVar --name success --type Boolean
// Connect to the database using the connection string and data is stored in the connection variable.
// Download the File "bdTechnologySQLiteConnect.db".
sqliteConnect --connectionString "Data Source=bdTechnologySQLiteConnect.db;Version=3;UseUTF16Encoding=True;" dbConnection=connection connectionString=connectionString dbPath=path success=success
// Check if the connection was successful
assert --message "Could not connect to the Database!" --left "${dbConnection}" --operator "Is_Null" --negate
logMessage --message "\r\nConnection String: ${connectionString}\r\nConnected to the database: ${success}" --type "Info"