Skip to content

SaltMySQLExecute

Executes non-SELECT SQL statements (INSERT, UPDATE, DELETE, DDL) against a MySQL database using configured credentials. Returns a human-readable summary and the raw JSON response from the underlying service.

Usage

Use this node to apply changes to a MySQL database or run administrative statements. It typically follows nodes that prepare or validate SQL and precedes nodes that consume the execution result (e.g., logging or branching on success). For data retrieval (SELECT), use the MySQL Query node instead.

Inputs

FieldRequiredTypeDescriptionExample
credentials_pathTrueSTRINGPath to the stored MySQL credentials configuration that the node will use to authenticate./workspace/credentials/mysql.json
timeoutFalseINTMaximum time in seconds to wait for the operation before failing.30
sql_textTrueSTRINGThe SQL statement to execute. Intended for INSERT, UPDATE, DELETE, and DDL (e.g., CREATE TABLE) statements.INSERT INTO users (name, email) VALUES ('John Doe', 'john@example.com')

Outputs

FieldTypeDescriptionExample
textSTRINGA formatted, human-readable summary of the execution outcome.MySQL Execute Results: 1 row affected
jsonJSONThe raw JSON response from the execution, which may include affected row count, status, and any returned metadata.{"affected_rows": 1, "status": "success"}

Important Notes

  • Non-SELECT only: Use this node for INSERT/UPDATE/DELETE/DDL. For SELECT queries, use the MySQL Query node.
  • Credentials required: Ensure the credentials file is valid, accessible by the runtime, and grants sufficient privileges for the statement.
  • SQL validation: The node does not rewrite or validate SQL; syntax and safety are the user's responsibility.
  • Timeouts: Long-running operations may need increased timeout values to avoid premature failure.
  • Idempotency: Re-running the same statement can cause duplicate changes. Consider transactions or checks when appropriate.

Troubleshooting

  • Syntax error in SQL: Verify the sql_text is valid MySQL syntax and matches your schema (tables, columns, data types).
  • Permission denied: Ensure the provided credentials have required privileges (e.g., INSERT/UPDATE/DELETE/CREATE).
  • Connection/timeout issues: Increase the timeout value and verify network access to the MySQL server.
  • Affected rows is zero: Confirm WHERE clauses are correct and that target rows exist.
  • Invalid credentials path: Check that credentials_path points to a valid configuration file and is readable by the node.