PostgreSQL Database Block
What it does: Connect your workflow to a PostgreSQL database to read, add, update, or delete data automatically.
In simple terms: Like having an assistant who can work with your database for you - finding information, adding new records, making changes, or removing old data whenever your workflow needs it.
When to Use This
Use the PostgreSQL block when you need to:
- ✅ Look up customer information from your database
- ✅ Save form submissions to your database
- ✅ Update order statuses automatically
- ✅ Remove outdated records
- ✅ Generate reports from database data
- ✅ Sync data between systems
Example: When a new order comes in, automatically save it to your database and update the customer's purchase history.
Key Features
- Read Data: Find and retrieve information from your database
- Add Data: Insert new records automatically
- Update Data: Modify existing records based on conditions
- Delete Data: Remove records when no longer needed
- Secure Connections: Connect safely with encrypted connections
- Use Results: Pass database results to other workflow blocks
Setup Guide
Step 1: Add Your Database Connection
You'll need these details from your database administrator:
| Setting | What It Is | Example |
|---|---|---|
| Host | Your database server address | db.mycompany.com |
| Port | Connection port (usually 5432) | 5432 |
| Database | The database name | production_db |
| Username | Your database login | workflow_user |
| Password | Your database password | (keep this secure!) |
Security Tip: Always use a dedicated database user with only the permissions needed for your workflow. Never use admin credentials.
Step 2: Choose Your Operation
Read Data (SELECT): Find and retrieve information
- Choose which table to read from
- Pick the columns you need
- Add filters to find specific records
- Sort results as needed
Add Data (INSERT): Create new records
- Select the target table
- Map your workflow data to table columns
- New records are added automatically
Update Data (UPDATE): Change existing records
- Choose which records to update using conditions
- Specify which fields to change
- Only matching records are modified
Delete Data (DELETE): Remove records
- Set conditions for which records to remove
- Only matching records are deleted
Step 3: Map Your Data
Connect workflow variables to database fields:
| Workflow Variable | Maps To | Example Value |
|---|---|---|
{{form.customerName}} | Customer Name column | John Smith |
{{form.email}} | Email column | john@email.com |
{{order.total}} | Order Amount column | 150.00 |
Common Use Cases
Save Form Submissions
When someone fills out a form, automatically save their information to your database. The workflow captures form data and inserts it as a new record.
Look Up Customer Information
When processing an order, look up the customer's details, preferences, and order history to personalize the experience.
Update Order Status
When an order ships, automatically update the order status in your database from "Processing" to "Shipped" along with the tracking number.
Generate Reports
Pull data from your database for specified date ranges or criteria, then use it to create automated reports.
Sync Between Systems
Read data from one source and update your PostgreSQL database to keep systems in sync.
What You Get Back
After the block runs, you receive:
- Success/Failure Status: Whether the operation completed successfully
- Row Count: How many records were affected
- Data Rows: The actual data (for read operations)
- Error Details: What went wrong (if anything)
Tips for Success
- Test with a small dataset first before running on all your data
- Always use filters when updating or deleting to avoid accidents
- Check your results to make sure you got what you expected
- Use descriptive names for your database columns to make mapping easier
Troubleshooting
| Problem | Likely Cause | Solution |
|---|---|---|
| Can't connect | Wrong credentials or firewall blocking | Double-check host, port, username, password |
| No data returned | Filter too strict or table empty | Adjust your conditions or check the table |
| Permission denied | User lacks access to table | Ask your admin to grant permissions |
| Data not saving | Required field missing | Make sure all required columns have values |
Best Practices
- Use SSL connections for production databases to keep data secure in transit
- Create a dedicated user for your workflows with limited permissions
- Log your operations to track what your workflow does to the database
- Handle errors gracefully by adding condition blocks to check for failures