DATABASE Export query to CSV function

Execute a SELECT query and write the results to a CSV file.

Help CentreBuilding Processes

This article describes the RPA Database functionality to export query results to a CSV file.

For a full list of available functions, please read DATABASE functions.


Description

The Export query to CSV function executes a SELECT query and writes the results to a CSV file. The first row of the output file contains the column headers.


Setting it up

To use the Export query to CSV function, follow these instructions:

{{popups:rpas/add:action=db-export-csv}}

Once on a process map:

  1. Navigate to the process where you would like to add the Export query to CSV function
  2. Click on the green button's drop-down (right side of the green button labelled "Process")
  3. On the menu that appears, click on the "+ Activity" item
  4. From here you can select the Export query to CSV option
  5. Click "Add" once you are done

Input parameters

ParameterRequiredTypeDefaultDescription
NameYesText-The alias of a previously opened connection (from db-connect)
QueryYesText-The SQL SELECT statement to execute
PathYesText-The file path where the CSV will be written
ParamsNoArray-An array of values for parameterised queries
DelimiterNoText,The column delimiter character

Output variables

This action does not produce output variables.


Errors

ErrorDescription
Connection not foundNo open connection exists with the specified name
Query errorThe SQL query contains a syntax error or references invalid objects
File write errorUnable to write to the specified file path

Tips

  • Use SELECT with specific column names rather than SELECT * to control the output format
  • Ensure the target directory exists before exporting
  • Use parameterised queries to safely include dynamic filter values

Related functions

See it working on your own data

Everything documented here ships with the platform – try the document tools free, or go live in 7 days.