1. Tasks
  2. Query Database

Tasks

Query Database

Connects to an external database and executes queries

Basic usage

loading...

Parameters

database_type
required
string

The type of database. Currently mysql and postgres are supported.


postgres/mysql
required
object

Contains the database specific parameters. If using postgres then the object should be postgres and if using mysql the object should be mysql.

See here for a MySQL example and here for a Postgres example.


postgres/mysql.query
required
object

The query to execute on the database.


postgres/mysql.connect_options.connecturl
required
object

The connection url to connect to the database.

To ensure that your connect url remains secret use credentials, example here.


Examples

Executing a query on a Postgres Database example

To execute a query on a Postgres Database, structure the task as follows, replacing the connecturl with your own connection url:

loading...

Executing a query on a MySQL Database example

To execute a query on a MySQL Database, structure the task as follows, replacing the connecturl with your own connection url:

loading...

Using Credentials for the connection url

It is possible to use credentials to ensure that your connection url remains secret and not displayed in the task on your template.

Create a new Generic credential and set the credential name to whatever you would like and set the Secret Value to your connection url.

After you create the credential, copy the credential UUID.

Structure the query_database as follows:

loading...

There is an additional parameter: org_credentials. Within this object, add a value for your Generic Credential UUID.

Set the connecturl value to use targeted substitution on your Generic Credential UUID in org_credentials.