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 |
---|---|
Host | The database host name (the location of the server) |
Port | The port number on which the database communicates |
Database Name | The name of the database instance |
User | The username to connect with |
Password | The password for the username to connect with |
Database Vendor | The database vendor — MySQL or PostgreSQL |
Parameters | Database-vendor specific key-value parameters (optional). For example, maxRows 5 limits the maximum number of returned rows to 5 (MySQL-specific) |
Query | The 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 |
---|---|
Host | mysql-db.example.com |
Port | 3306 |
Database Name | employees |
User | root |
Password | password |
Database Vendor | mysql |
Parameters | key: connectTimeout value: 5 |
Query | ${@query[0]} |
Sample PostgreSQL settings
Property | Value |
---|---|
Host | postgresql-db.example.com |
Port | 5432 |
Database Name | employees |
User | john |
Password | postgres |
Database Vendor | postgresql |
Parameters | key: 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)")