Workflows
Blocks
Database
MySQL

MySQL Database Block

What it does: Connect your workflow to a MySQL database to read, add, update, or delete data automatically.

🗄️

In simple terms: MySQL is one of the most popular databases in the world. This block lets your workflow talk to your MySQL database - finding records, adding new ones, making changes, or cleaning up old data.

When to Use This

Use the MySQL block when you need to:

  • ✅ Query customer records from your database
  • ✅ Save new entries like orders or signups
  • ✅ Update existing records based on workflow events
  • ✅ Remove outdated or processed entries
  • ✅ Pull data for reporting and analysis
  • ✅ Keep systems synchronized

Example: When an order is received, save it to MySQL, update inventory counts, and mark the customer as an active buyer.

Key Features

  • Read Data: Query tables to find matching records
  • Add Data: Insert new rows into your tables
  • Update Data: Change existing records with precision
  • Delete Data: Remove records you no longer need
  • Multiple Tables: Work with any table in your database
  • Secure Connection: Connect with encrypted credentials

Setup Guide

Step 1: Add Your Database Connection

Gather these details from your database administrator:

SettingWhat It IsExample
HostDatabase server addressdb.mycompany.com
PortConnection port (default: 3306)3306
DatabaseThe database nameecommerce_db
UsernameYour database loginapp_user
PasswordYour database password(keep secure!)
🔒

Security Tip: Use a dedicated database user for your workflows with only the permissions needed. Never use root or admin accounts!

Step 2: Choose Your Operation

Read (SELECT): Find and retrieve data

  • Pick the table to query
  • Select which columns to return
  • Add conditions to filter results
  • Sort and limit as needed

Add (INSERT): Create new records

  • Choose the target table
  • Map your data to table columns
  • Records are added automatically

Update (UPDATE): Modify existing records

  • Set conditions to find records
  • Specify which fields to change
  • Only matching records are updated

Delete (DELETE): Remove records

  • Set conditions for what to delete
  • Only matching records are removed

Step 3: Map Your Data

Connect workflow variables to database columns:

Workflow VariableDatabase ColumnExample Value
{{customer.name}}customer_nameJane Doe
{{customer.email}}email_addressjane@email.com
{{order.amount}}total_price99.99
{{order.date}}order_date2024-01-15

Common Use Cases

Store New Orders

When customers place orders through your website or app, automatically save the order details to your MySQL database with timestamps and status tracking.

Customer Lookup

Before processing a request, look up the customer's information, order history, and preferences to personalize the experience.

Inventory Updates

When products are sold or restocked, automatically update inventory counts in your database to keep stock levels accurate.

Generate Reports

Pull sales data, customer statistics, or activity logs from MySQL to create automated reports and dashboards.

User Registration

When new users sign up, store their account information securely in your database with proper timestamps.

What You Get Back

After the block runs, you receive:

  • Query Results: The matching rows of data (for read operations)
  • Inserted ID: The ID of newly created records
  • Rows Affected: Count of records updated or deleted
  • Status: Success or failure information
  • Error Details: Explanation if something went wrong

Tips for Success

  1. Always use conditions when updating or deleting to avoid affecting all records
  2. Test with SELECT first to verify your conditions match the right records
  3. Map data types correctly - numbers should be numbers, dates should be dates
  4. Use descriptive column names to make mapping easy and clear
  5. Include timestamps in your tables for tracking when data changes

Troubleshooting

ProblemLikely CauseSolution
Connection refusedWrong host/port or firewallVerify connection settings and network access
Access deniedInvalid credentialsDouble-check username and password
Table not foundWrong table or database nameVerify table exists in the correct database
Data truncatedValue too large for columnCheck column sizes match your data

Best Practices

  • Use parameterized queries to prevent security issues
  • Create dedicated database users for workflow access
  • Enable SSL connections for production databases
  • Log all operations for debugging and auditing
  • Handle errors gracefully with condition blocks in your workflow
Indite Documentation v1.4.0
PrivacyTermsSupport