Skip to main content

Query Database

ComponentTypeDescription
imgQuery Database🔀 actionRetrieve a database record using a query

The Query Database component allows you to run a query to extract data from a database. For example, you can run a query to return all values in the "username" column when the values in the "order amount" column is greater than 50.

The output of the Query Database component is a list of values, which can then be passed into the List Transform component for further processing if required.

Configuring the query​

Select a database from the dropdown menu and then click Get Data.

img

This will load a preview of the database.

img

Click Add Data Query to create a query. You can create multiple queries inside of a single Query Database component.

img

Select the output of the query. There are two options:

Query and return all values in a column​

This will output all the data in a column as a list i.e. returns all values in Column A.

img

Query and return values if a condition is met​

This will return the data in a column that meets a certain condition e.g. return the data in "test" column which matches "Test data 5".

You can also use this to return the values in one column where the values in another meets a condition e.g. return the values in Record ID where the values in test matches "Test data 1".

img

Query involving datetime columns or values​

When performing a query involving a datetime column, you can select whether to perform a query with a datetime placeholder (e.g. "return values from Date column where value is greater than subscription_start_date" or a specific datetime value e.g. return values from Date column where value less than 12 march 2024).

img

To perform a query against a datetime placeholder, select the datetime placeholder or type in an ISO8601 compliant datetime value:

img

To perform a query against a specific datetime value, select the date and time via the picker:

img

Changing the query database output format​

You can select how the results of the query database are returned by clicking on the dropdown below to select whether to return the results as a list, or as a string.

img

Return query output as a list​

By default, the query database will return a list placeholder with a list of values from the query. For example, if the results of a query are "John, Jane, Jack" then this will be outputted as list placeholder with the value ["John", "Jane", "Jack"]. This occurs even if there is only one value that is returned i.e. if the only result from the query is "John" then the output will be a list placeholder ["John"].

Return query output as a string/text​

You can also choose to have the output of the query returned as a string i.e. without the outer square brackets. This means the results "John, Jane, Jack" will be returned as a text/string placeholder with the value "John, Jane, Jack".

tip

Return query output as a string/text when you need to work with the values without the outer square brackets that would be there if you chose to output as a list. For example, when you want to print the values of the query in a form or task.

Output format when querying a list column​

When you are querying a list column, this will be returned as a list of a list i.e [["John", "Jane", "Jack"]]. You can choose to change this to output a text placeholder with the values as a string "John", "Jane", "Jack" (removing all square brackets) or to have the output returned as a list placeholder with only the outer brackets like this ["John", "Jane", "Jack"].

img

note

What happens if the component encounters an error with one query?

If there are multiple queries in the Query Database component and a error is encountered with a particular query, the component will skip that query and continue running the next query. An error message will be returned in the session logs.