MySQL Block
Execute SQL queries and manage data in MySQL databases
The MySQL block connects to a MySQL database to execute queries and perform full CRUD operations on your data. Reach for it when a workflow needs to read from or write to MySQL, with support for secure SSL connections, parameterized queries, and connection pooling.
Overview
| Property | Value |
|---|---|
| Type | mysql |
| Category | tools |
| Color | #FFFFFF |
When to Use
- Run ad-hoc
SELECTqueries to pull records into a workflow for downstream processing. - Insert new rows into a table from data produced by an upstream block or agent.
- Update existing rows that match specific WHERE conditions.
- Delete rows that match specific WHERE conditions.
- Persist workflow results or AI-generated output into an application database.
- Connect to a remote MySQL instance over an SSL/TLS-encrypted connection.
Configuration
Host (host) — required
The MySQL server hostname or IP address (e.g. localhost or db.example.com).
Port (port)
The TCP port MySQL listens on. Defaults to 3306 if left blank.
Database (database) — required
The name of the target database to connect to.
Username (username) — required
The database user to authenticate as (e.g. root).
Password (password)
The password for the database user. Leave empty for passwordless or socket-based local authentication. The field is masked.
Enable SSL (ssl)
A toggle (switch). When enabled, the connection uses SSL/TLS encryption (ssl: { rejectUnauthorized: false }).
Action (action) — required
A dropdown that selects the database operation to perform. This controls which additional configuration fields are shown.
| Label | ID | Additional fields shown |
|---|---|---|
| Execute Query | execute | query |
| Insert Data | insert | table, data |
| Update Data | update | table, data, conditions |
| Delete Data | delete | table, conditions |
SQL Query (query)
A SQL code editor for the raw SQL statement to execute. Shown only when action is execute. Required in that mode. Supports the wand (AI-assist) feature to generate MySQL queries from natural language; you can reference other blocks with {{blockName.field}} or environment variables with {{ENV_VAR_NAME}}.
Table Name (table)
The name of the target table. Shown when action is insert, update, or delete. Required in those modes.
Data (data)
A JSON editor for the values to write. Accepts a single object or an array of objects. Shown when action is insert or update. Required in those modes. Supports AI-assist for generating valid JSON payloads; reference upstream block output with {{blockName.field}}.
Conditions (WHERE clause) (conditions)
A JSON editor defining the WHERE conditions used to target specific rows. Shown when action is update or delete. Required in those modes. Example: {"id": 123} or {"status": "active"}.
Inputs & Outputs
Inputs (all map directly to the sub-block ids above):
host(string) — MySQL hostname or IP addressport(number) — MySQL port (default: 3306)database(string) — Database nameusername(string) — Database usernamepassword(string) — Database passwordssl(boolean) — Enable SSL connectionaction(string) — Operation to perform (execute,insert,update, ordelete)query(string) — SQL query to execute (used when action isexecute)table(string) — Table name for insert/update/delete operationsdata(json) — Data object or array of objects for insert/update operationsconditions(json) — WHERE conditions for update/delete operations
Outputs:
data(json) — Query results for SELECT operations; for write operations contains a result summary objectaffectedRows(number) — Number of rows affected by INSERT, UPDATE, or DELETE operationsmetadata(json) — Query execution metadata includingexecutionTime,rowCount, andcolumnserror(string) — Error message if the operation failserrorDetails(json) — Detailed error information including error type and execution time
Tools
MySQL (mysql_database) — Executes SQL queries and manages data in a MySQL database. Handles all four action modes (execute, insert, update, delete) by routing to the appropriate query path, uses connection pooling (connectionLimit: 10, connectTimeout: 30 s), and sanitizes identifiers to prevent injection. Returns structured output including result rows, affected row counts, and timing metadata.
YAML Example
mysql_1:
type: mysql
name: "MySQL"
inputs:
host: "db.example.com"
port: 3306
database: "my_database"
username: "root"
password: "{{DB_PASSWORD}}"
ssl: true
action: "execute"
query: "SELECT * FROM users WHERE active = 1"
connections:
outgoing:
- target: next-block-idInsert example
mysql_insert:
type: mysql
name: "Insert User"
inputs:
host: "db.example.com"
port: 3306
database: "my_database"
username: "app_user"
password: "{{DB_PASSWORD}}"
ssl: false
action: "insert"
table: "users"
data: '{"name": "{{agent1.name}}", "email": "{{agent1.email}}", "active": true}'
connections:
outgoing:
- target: next-block-idUpdate example
mysql_update:
type: mysql
name: "Deactivate User"
inputs:
host: "db.example.com"
port: 3306
database: "my_database"
username: "app_user"
password: "{{DB_PASSWORD}}"
ssl: false
action: "update"
table: "users"
data: '{"active": false}'
conditions: '{"id": "{{trigger.userId}}"}'
connections:
outgoing:
- target: next-block-id