MySQL Query¶
Executes a read-only SQL SELECT query against a MySQL database using configured credentials. Returns a human-readable summary and a JSON payload by default, with compatibility for additional formatted outputs via shared database helpers.
Usage¶
Use this node when you need to fetch data from a MySQL database within a Salt workflow. Provide valid MySQL credentials and a SELECT statement; the node will run the query and produce text and JSON outputs you can route to downstream processing, visualization, or export nodes. For DML (INSERT/UPDATE/DELETE), use the dedicated execute node instead.
Inputs¶
| Field | Required | Type | Description | Example |
|---|---|---|---|---|
| credentials_path | True | CREDENTIALS | Path or reference to stored MySQL credentials. The credential should include host, port, database, username, and password configured for the MySQL service. | |
| timeout | False | INT | Request timeout in seconds for the database operation. | 60 |
| sql_text | True | STRING | A SQL SELECT query to execute. Must be a read-only statement. | SELECT id, email FROM users ORDER BY created_at DESC LIMIT 100 |
Outputs¶
| Field | Type | Description | Example |
|---|---|---|---|
| text | STRING | Human-readable summary of the query results (e.g., row count and formatted rows). | MySQL Query Results (10 rows): ... |
| json | STRING | JSON string containing the raw result data for programmatic use. | {"data": [{"id": 1, "email": "user@example.com"}], "row_count": 1} |
| html | Not specified | HTML-rendered table of results (may be empty when using default output mode). | |
| xlsx | Not specified | Spreadsheet data for results in XLSX format (may be empty when using default output mode). | |
| Not specified | PDF data for results (may be empty when using default output mode). |
Important Notes¶
- Read-only: This node is intended for SELECT queries. Use SaltMySQLExecute for INSERT/UPDATE/DELETE.
- Credentials required: Ensure the provided credentials have sufficient privileges to execute the query and access the target database/tables.
- Timeouts: Large or complex queries may require increasing the timeout to prevent premature termination.
- Result formats: By default, text and JSON are returned; additional formats (HTML/XLSX/PDF) are supported by shared helpers and may be empty unless explicitly generated by compatible nodes.
- SQL safety: Avoid concatenating untrusted input into the SQL string to prevent SQL injection. Parameterization is not handled automatically by this node.
Troubleshooting¶
- Authentication failed: Verify host, port, database name, username, and password in the credentials reference.
- Network/connectivity errors: Confirm the MySQL server is reachable from the environment where the workflow runs and that firewalls/security groups allow access.
- Permission denied: Ensure the database user has SELECT privileges on the referenced tables and schemas.
- SQL syntax error: Validate the SQL in sql_text. Test it directly against the database to confirm correctness.
- Empty results: Confirm the WHERE clause and target tables contain data matching your criteria.
- Timeouts or very slow queries: Increase the timeout input, add indexes, simplify the query, or limit the result set (e.g., add LIMIT).