Skip to content

SaltPostgresExecute

Executes PostgreSQL data-manipulation SQL (INSERT, UPDATE, DELETE) against a configured database via Salt's CData service. Returns a human-readable summary and the raw JSON response, typically including rows affected and status details.

Usage

Use this node when you need to modify data in a PostgreSQL database as part of your workflow, such as inserting new records, updating existing ones, or deleting rows. Provide valid database credentials and a DML SQL statement; the node will execute it and emit both a summary string and a JSON payload for downstream logic or logging.

Inputs

FieldRequiredTypeDescriptionExample
credentials_pathTrueSTRINGPath or reference to the stored PostgreSQL credentials that the node will use to authenticate with the database.secrets/postgres.json
timeoutFalseINTMaximum time in seconds to wait for the execution request before it times out.60
sql_textTrueSTRINGThe SQL statement to execute. Intended for INSERT, UPDATE, or DELETE statements (not SELECT).INSERT INTO users (name, email) VALUES ('John Doe', 'john@example.com')

Outputs

FieldTypeDescriptionExample
textSTRINGA human-readable summary of the execution result, suitable for display or logging.PostgreSQL Execute Results: 1 row affected.
jsonJSONRaw JSON response from the execution service, typically including status and rows affected.{"status": "success", "rows_affected": 1}

Important Notes

  • DML only: This node is designed for INSERT, UPDATE, and DELETE. Use the corresponding query node for SELECT statements.
  • Credentials required: Ensure the credentials at credentials_path are valid and have appropriate permissions for the target tables.
  • SQL safety: Avoid constructing SQL from untrusted inputs to prevent SQL injection. Prefer parameterized statements where possible.
  • Timeout behavior: Long-running statements may require increasing the timeout input to prevent premature failures.
  • Service-backed execution: The node proxies execution through Salt's CData PostgreSQL service; network availability and service health can affect results.

Troubleshooting

  • Syntax error in SQL: Validate your SQL with a psql client or linter and correct any syntax issues.
  • Permission denied: Verify the database user in credentials has privileges for the target schema/table and the specific operation.
  • Connection or service error: Check network access to the service, confirm the credentials_path is correct, and retry. Increase timeout if needed.
  • 0 rows affected: Confirm your WHERE clause or target data is correct; the command may have executed successfully but matched no rows.
  • Statement times out: Increase the timeout input or optimize the statement (e.g., add indexes) to reduce execution time.