1. Tasks
  2. Query Database

Tasks

Query Database

Executes queries against external databases such as PostgreSQL, MySQL, MSSQL or Neo4j. Useful for lookups, reporting, validation, and database-backed integrations.

Basic usage

loading...

Parameters

database_type
required
string

The type of database. Currently mysql, postgres, mssql and neo4j are supported.


postgres/mysql/mssql/neo4j
required
object

Contains the database specific parameters. If using postgres then the object should be postgres. If using mysql the object should be mysql. If using mssql then the object should be mssql. If using neo4j then the object should be neo4j.

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


postgres/mysql/mssql/neo4j.query
required
object

The query to execute on the database.


postgres/mysql/mssql/neo4j.connect_options.connecturl
required
object

The connection url to connect to the database.

Database Example Connection String
Microsoft SQL Server Server=myServerAddress;Database=myDataBase;User Id=myUsername;Password=myPassword;TrustServerCertificate=True;
MySQL Server=myServerAddress;Port=3306;Database=myDataBase;Uid=myUsername;Pwd=myPassword;
PostgreSQL Host=myServerAddress;Port=5432;Database=myDataBase;Username=myUsername;Password=myPassword;
Neo4j neo4j://myUsername:myPassword@myServerAddress:7687

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...

Executing a query on a MSSQL Database example

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

loading...

Executing a query on a Neo4j Database example

To execute a query on a Neo4j 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.