FluxyAPIFluxyAPI
BlocksDatabase

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

FieldRequiredDescription
ConnectionSelect your MySQL or MariaDB database connection.
OperationChoose the action: Find One, Find Many, Insert One, Update, Delete, Count, or Raw SQL Query.
Table NameThe 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 ConditionsDefine which rows to target (WHERE clause) using a visual builder.
Columns to SetDefine which columns to update or insert values into.
Output VariableThe variable to store the result rows or operation status.
Security First

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

  1. Setup: Select your "Customer DB" connection.
  2. Operation: Set Operation to Raw SQL Query.
  3. Query: Enter SELECT name, email FROM users WHERE status = ? AND age > ?.
  4. Parameters:
    • Add {request.query.status} for the first ?.
    • Add 18 for the second ?.
  5. 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]"}].

On this page