MySQL / MariaDB
Execute SQL queries and manage rows in your MySQL or MariaDB database.
The MySQL / MariaDB block provides a powerful interface for interacting with relational databases. You can perform standard CRUD operations using a visual builder or execute raw, parameterized SQL queries.
Core Concept
A MySQL database is like a spreadsheet with fixed columns. This block lets you "read" rows, "insert" new rows, or "update" existing data. For complex needs, you can write your own SQL, but the block handles the security of injecting your variables safely.
Configuration
| Field | Required | Description |
|---|---|---|
| Connection | ✅ | Select your MySQL or MariaDB database connection. |
| Operation | ✅ | Choose the action: Find One, Find Many, Insert One, Update, Delete, Count, or Raw SQL Query. |
| Table Name | ✅ | The name of the table to target (e.g., users or products). (Not used for Raw Query). |
| SQL Query | ✅ | (Raw Mode) Your SQL string. Use ? as placeholders for parameters (e.g., SELECT * FROM users WHERE id = ?). |
| Query Parameters | — | (Raw Mode) List the values to replace the ? placeholders in order. |
| Filter Conditions | — | Define which rows to target (WHERE clause) using a visual builder. |
| Columns to Set | — | Define which columns to update or insert values into. |
| Output Variable | ✅ | The variable to store the result rows or operation status. |
Always use the Query Parameters list or the visual builder when working with user input. Never concatenate variables directly into a Raw SQL Query string to prevent SQL injection attacks.
Variable Syntax Rules
- Single braces only:
{variable_name}. - Library variables:
{MY_VAR}. - Request data:
{request.body.field}or{request.query.field}. - Never use
{{double_braces}}.
Error Handling
FIELD_MISSING— Triggered when required fields like Connection or Table Name are missing.CONNECTION_FAILED— Triggered if the connection to the MySQL server fails.OPERATION_FAILED— Triggered if the SQL query is invalid or the operation is rejected by the server.BUILDER_FAILED— Triggered if the visual builder cannot construct a valid SQL query from your inputs.
Example
- Setup: Select your "Customer DB" connection.
- Operation: Set Operation to
Raw SQL Query. - Query: Enter
SELECT name, email FROM users WHERE status = ? AND age > ?. - Parameters:
- Add
{request.query.status}for the first?. - Add
18for the second?.
- Add
- Variable: Set Output Variable to
active_users.
Result: {active_users} will contain an array of objects matching your query, such as [{"name": "Alice", "email": "[email protected]"}].
