Write Database

Summary

Writes data to a MySQL or PostgreSQL database. Provide connection details and a query.

Properties

The following table lists the Write Database block properties and describes the input for each property.

Property
Description
HostThe database host name (the location of the server)
PortThe port number on which the database communicates
Database NameThe name of the database instance
UserThe username to connect with
PasswordThe password for the username to connect with
Database VendorThe database vendor MySQL or PostgreSQL
ParametersDatabase-vendor specific key-value parameters (optional). For example, maxRows 5 limits the maximum number of returned rows to 5 (MySQL-specific)
QueryThe SQL query to send. If the Input block is renamed to "query", enter ${@query[0]}, which means that the actual SQL query is what you type inside the flow function's parentheses (see the example below)

Sample MySQL settings

Property
Value
Hostmysql-db.example.com
Port3306
Database Nameemployees
Userroot
Passwordpassword
Database Vendormysql
Parameterskey: connectTimeout value: 5
Query${@query[0]}

Sample PostgreSQL settings

Property
Value
Hostpostgresql-db.example.com
Port5432
Database Nameemployees
Userjohn
Passwordpostgres
Database Vendorpostgresql
Parameterskey: connectTimeout value: 5
Query${@query[0]}

Flow example

The following describes an example of a flow with the Write Database block.

The flow "WRITE_TO_DB" in this example is made up of three blocks:

  • Input block (name: "query", type: String)
  • Write Database block with the Query property set to ${@query[0]}
  • Default Output block

Below is a formula used to invoke this flow:

=WRITE_TO_DB("INSERT INTO users(first_name, last_name, age) VALUES('Michael','Scott',25)")
Copy to clipboard
Contents