Terminate SQL Connection

Terminates a connection with a 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.

sqlDisconnect --connection(DbConnection) [--timeout(TimeSpan)]


Before you terminate the connection to the database, you must create a database connection with a valid connection string. Use the following commands according to the database management system (DBMS) you use:

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 connection Required Database Connection Database connection variable.
Timeout timeout Optional Time Span, Number, Text Maximum waiting time to terminate the connection.

The default timeout is 5 seconds. You can use the Set Timeout command to set the default timeout of the script.


The following code example demonstrates how to terminate a connection established with a database. Consider that you have an empty database file called sample.db.

defVar --name dbConnection --type DbConnection
defVar --name pathMyDocuments --type String
defVar --name databaseFile --type String
// Gets the My Documents folder path.
getSpecialFolder --folder "MyDocuments" pathMyDocuments=value
// Assigns the 'sample.db' folder path to the 'databaseFile' variable.
setVar --name "${databaseFile}" --value "${pathMyDocuments}\\sample.db"
// Connects to the database management system (DBMS). You must provide a valid connection string to connect with the database before you run this example.
sqliteConnect --connectionString "Data Source=${databaseFile};Version=3;UseUTF16Encoding=True;" dbConnection=connection
// Create a new table called 'sample_table'.
sqlExecute --connection ${dbConnection} --statement "CREATE TABLE sample_table (\r\n sample_column TEXT NOT NULL\r\n);" --timeout "00:08:40"
// Terminates a connection to the database.
sqlDisconnect --connection ${dbConnection}