On this page
Sommatic Docs
Open portal

MySQL - Query

Execute SQL queries on MySQL and MariaDB databases.

View as Markdown
Open in
Integrations Available integrations.oracle.mysql.query Version 1.0.0 Execution: async

Runs one prepared SQL statement on MySQL with positional ? parameters and returns the rows (or the write result) under result.

Connect your MySQL instance and run parameterized queries with positional ? binding for SQL injection prevention. Compatible with MySQL, MariaDB, and similar databases.

Operations:

  • SELECT: Fetch rows from tables with filters, joins, and aggregations.
  • INSERT: Add new records to tables.
  • UPDATE: Modify existing records matching a condition.
  • DELETE: Remove records from tables.
  • Stored Procedures: Call stored procedures via CALL statements.
  • DDL: Execute CREATE, ALTER, DROP statements for schema management.

How it works

  1. Resolves the expressions of the node config. Empty connection_id and sql fall back to the incoming item. Parameters are read from the undeclared params key, then from the incoming item's parameters; the declared parameters key is not read.
  2. Resolves the connection: a mysql:// / mysql2:// URI in connection_id, a connection-string credential, or a basic-auth / object credential with username, password, host, database and port (default 3306). Dates are returned as strings.
  3. Runs sql as a prepared statement with the parameters (a single value is wrapped in an array) and closes the connection.
  4. Returns { result } on out: the rows for SELECT (an empty array when none) or the driver's result header (affectedRows, insertId…) for writes.

In a workflow

The node as it appears in a workflow file (draft_nodes[]), and the envelope of a successful run.

{
  "node_id": "node-find-customer",
  "label": "Find customer",
  "operator_slug": "integrations.oracle.mysql.query",
  "operator_version": "1.0.0",
  "config": {
    "connection_id": "pi-credential-xxxx",
    "sql": "SELECT id, email, created_at FROM customers WHERE email = ?",
    "params": [
      "{{ $json.email }}"
    ]
  }
}

Configuration

connection_id string Required

Credential for your MySQL instance. Accepts credentials of type `connection-string` (mysql:// URI) or `basic-auth` (username + password + host + database).

sql string Required Accepts expressions

The SQL statement to execute (e.g., "SELECT * FROM users WHERE id = ?").

parameters array Optional

Array of values for positional ? parameter binding.

Behaviour in the code

What the implementation does with these keys beyond what the schema says.

parameters
Declared in the schema but not read by the worker. Put the values in params instead.
params Read by the code, not declared
Undeclared key that holds the positional values for ?. A non-array value is sent as a single parameter.

Output ports

out default

The statement ran, with or without rows.

Data
{
  "result": [
    {
      "id": 42,
      "email": "ana@example.com",
      "created_at": "2026-11-20 15:04:05"
    }
  ]
}
error

Validation, credential resolution, the connection or the statement failed.

Data
{
  "error": "Incorrect arguments to mysqld_stmt_execute"
}

In expressions

What a later node can read from this node's output with $("MySQL - Query").item.json.<path> (write your node's label instead of MySQL - Query). Editor marks the paths the workflow editor suggests under Previous Nodes (the output contract); Worker marks the paths the worker really returns through out, from the output shown in Ports.

ExpressionEditorWorker
$("MySQL - Query").item.json.resultarray= […] (1)Array of rows returned by the query

Errors

Message Port Cause and fix
connection_id is required error No credential in the config or in the incoming item.
sql query is required error sql is empty.
Incorrect arguments to mysqld_stmt_execute error The number of parameters does not match the ? placeholders. Common cause: the values were set in parameters, which this node ignores; use params.
Credential <connection_id> has unsupported type '<type>' for integrations.oracle.mysql.query. Use 'connection-string' or 'basic-auth'. error The credential type is not supported by this node.

Input contract

connection_id string Required
sql string Required
parameters array Optional

Output contract

result array<object> Optional

Array of rows returned by the query

Contracts (JSON Schema)

The definition exactly as the orchestrator declares it. All is the whole *.definition.js; compare it with the sections above to spot differences between the documentation and the schema. Use it to validate a node before you publish.

{
  "slug": "integrations.oracle.mysql.query",
  "name": "MySQL - Query",
  "category": "integrations",
  "version": "1.0.0",
  "description": "Execute SQL queries on MySQL and MariaDB databases.\n\n  Connect your MySQL instance and run parameterized queries with positional ? binding for SQL injection prevention. Compatible with MySQL, MariaDB, and similar databases.\n\n  **Operations:**\n  - **SELECT:** Fetch rows from tables with filters, joins, and aggregations.\n  - **INSERT:** Add new records to tables.\n  - **UPDATE:** Modify existing records matching a condition.\n  - **DELETE:** Remove records from tables.\n  - **Stored Procedures:** Call stored procedures via CALL statements.\n  - **DDL:** Execute CREATE, ALTER, DROP statements for schema management.",
  "capabilities": [
    "sql",
    "database",
    "mysql",
    "mariadb"
  ],
  "group": [
    {
      "key": "oracle",
      "name": "Oracle",
      "icon_url": "/icons/integrations/oracle/oracle.svg"
    },
    {
      "key": "mysql",
      "name": "MySQL",
      "icon_url": "/icons/integrations/oracle/mysql.svg"
    }
  ],
  "icon_url": "/icons/integrations/oracle/mysql.svg",
  "config_schema": {
    "type": "object",
    "properties": {
      "connection_id": {
        "type": "string",
        "title": "MySQL Credential",
        "description": "Credential for your MySQL instance. Accepts credentials of type `connection-string` (mysql:// URI) or `basic-auth` (username + password + host + database).",
        "ui_widget": "connection_picker",
        "ui_options": {
          "credential_types": [
            "connection-string",
            "basic-auth"
          ],
          "types": [
            "mysql"
          ]
        }
      },
      "sql": {
        "type": "string",
        "title": "SQL Query",
        "description": "The SQL statement to execute (e.g., \"SELECT * FROM users WHERE id = ?\").",
        "format": "expression",
        "ui_widget": "sql_editor"
      },
      "parameters": {
        "type": "array",
        "title": "Query Parameters",
        "description": "Array of values for positional ? parameter binding."
      }
    },
    "required": [
      "connection_id",
      "sql"
    ]
  },
  "input_contract_schema": {
    "type": "object",
    "properties": {
      "connection_id": {
        "type": "string"
      },
      "sql": {
        "type": "string"
      },
      "parameters": {
        "type": "array"
      }
    },
    "required": [
      "connection_id",
      "sql"
    ]
  },
  "output_contract_schema": {
    "type": "object",
    "properties": {
      "result": {
        "type": "array",
        "items": {
          "type": "object"
        },
        "description": "Array of rows returned by the query"
      }
    }
  },
  "ports": [
    {
      "port_id": "out",
      "label": "Rows",
      "description": "Resulting rows from the query",
      "is_default": true,
      "supports_condition": true
    },
    {
      "port_id": "error",
      "label": "Error",
      "description": "Error occurred during execution",
      "is_default": false,
      "supports_condition": false
    }
  ],
  "execution_mode": "async",
  "required_resources": [],
  "compatible_worker_pools": [
    "standard-io",
    "db-io"
  ],
  "tags": [
    "sql",
    "database"
  ],
  "is_stateful": false,
  "publisher": {
    "identity": "org_sommatic_ai",
    "profile": {
      "name": "Sommatic AI",
      "verified": true,
      "url": "https://sommatic.ai",
      "logo_url": null
    }
  }
}

Execution

Execution
async
Stateful
No
Credentials
Resolved on the server from connection_id; the secret never reaches the workflow.
Capabilities
sqldatabasemysqlmariadb
Tags
sqldatabase

Notes and limits

  • There is no empty port: a SELECT with no rows leaves through out with result: [].
  • A new connection is opened and closed on every run; the node does not retry.

Reviewed against the orchestrator code · 31e874b · 2026-11-26

Install agent tools

Give your coding agent the official Sommatic AI docs: skills, the docs MCP server and Markdown pages, so it never has to scrape the site.

Skills only. They do not update by themselves; run it again to refresh.

npx skills add https://docs.sommatic.ai
How agents read these docs