Connect to SQLite

Connects to an SQLite database.

Command availability: IBM RPA SaaS and IBM RPA on premises

Description

Establishes a connection with an SQLite Server database.

Dependencies

You need a valid connection string to the SQLite database. See the connectionstring parameter for examples of valid connection strings.

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 RPA Studio's Script mode.

sqliteConnect [--createNew(Boolean)] --connectionString(String) [--sql(String)] [--path(String)] [--password(String)] (DbConnection)=connection (String)=connectionString (String)=path (Boolean)=success

Input parameters

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 RPA Studio's Script mode and its Designer mode equivalent label.

Designer mode label Script mode name Required Accepted variable types Description
Create New createNew Optional Boolean Enable it to create a new SQLite database.
Connection String connectionString Required when the Create New parameter is disabled Text Connection string to connect to the SQLite Database.

See the connectionstring parameter section for details.
SQL Command sql Optional Text SQLite commands to create the SQLite Database tables and data insertion. This field accepts any SQL command.
Path path Optional Text Full file path to where the SQLite file is created.
Password password Optional Text The password to access the database.

connectionstring parameter

The connectionstring parameter is where you enter the string that includes key-value pairs providing the necessary information to connect to the Oracle database. The following code block is an example of a valid connection string:

Data Source=/path/to/your/database.db;Version=3;

Replace the Data Source path with your actual SQLite database file path.

Output parameters

Designer mode label Script mode name Accepted variable types Description
Connection connection Database Connection Connection to the SQLite Database.
Connection String connectionString Text Connection string to access the SQLite database.
Path path Text Full path of the SQLite Database file that is returned when IBM RPA Studio creates the database.
Success success Boolean Returns "True" if the connection to the SQLite Database is successfully created, and False otherwise.

Example

This example connects to an SQLite database by using the Assert Condition (assert) command to verify whether the connection was successful. The message "Could not connect to the Database!" is displayed if the connection is empty.

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