Using the Read from action
Use the Read from action to retrieve records from the database and save the retrieved data in a CSV file. This action enables you to retrieve up to one million records from the database.
Procedure
To automate the task of selecting and saving a set of records, follow these steps:
- Enter the name of the session you used to connect to the database server in
the Connect
action.
You do not have to provide the details of the database server here because you have already associated those details with the session name when using the Connect action.
-
Enter the SELECT statement to specify the column and table names.
This field supports SQL syntax. For example,
SELECT CustomerName,City FROM Customers
Note: CTE (Common Table Expression) is supported usingWITH
keyword in the SQL compliant databases such as Oracle and MySQL. For example,WITH customers_in_usa AS (SELECT CustomerName, state FROM customers WHERE country = 'USA') SELECT cName FROM customers_in_usa WHERE state = 'LA' ORDER BY CustomerName
- Enter the maximum number of records to retrieve.
- Optional:
Enter a timeout value.
When the specified time expires, the statement execution stops even if the execution is not completed.
-
Select the Export data to CSV option to save the
retrieved data.
- Select the file path from the Bots folder, the local device, or an existing file variable.
- Select the CSV file encoding to be either ANSI, UNICODE, or UTF8.
-
Select whether to export the CSV file with or without the column
headers.
With column headers
CustomerName City Manny Pittsburgh Kate Los Angeles John Boston Without column headersManny Pittsburgh Kate Los Angeles John Boston - Specify whether to overwrite the file or append the data to the existing file if a CSV file with the same name exists.
- Click Save.