Skip to main content

Export Query

Exports the results of a SQL query to a file.

Common Properties

  • Name - The custom name of the node.
  • Color - The custom color of the node.
  • Delay Before (sec) - Waits in seconds before executing the node.
  • Delay After (sec) - Waits in seconds after executing node.
  • Continue On Error - Automation will continue regardless of any error. The default value is false.
info

If the ContinueOnError property is true, no error is caught when the project is executed, even if a Catch node is used.

Inputs

  • Connection Id - The identifier of the database connection to use.
  • Transaction Id - The identifier of the transaction to use (optional).
  • Export Path - The file path where the query results will be exported.
  • SQL Export - The SQL query to execute (supports template variables).

Options

  • Seperator - The character used to separate values in the exported file. Options are:
    • semicolon (;)
    • comma (,)
    • tab (\t)
    • space ( )

How It Works

The Export Query node executes a SQL query and exports the results to a file. When executed, the node:

  1. Validates the provided Connection Id and Export Path inputs
  2. Looks up the database connection in the SQLite connection pool
  3. If provided, looks up the transaction in the SQLite transaction store
  4. Deserializes message data for use in SQL template variables
  5. Renders the SQL query using template variables with Stubble template engine
  6. HTML decodes the rendered SQL query
  7. Creates and executes a SQLite command with the rendered query
  8. Reads the query results using a data reader
  9. Writes the column headers and data rows to the specified export file
  10. Uses the selected separator character between values

Requirements

  • A valid database connection identifier from the Connect node
  • Valid file path with write permissions for the export file
  • Valid SQL query that returns data
  • Sufficient disk space for the exported file

Error Handling

The node will return specific errors in the following cases:

  • Empty or invalid Connection Id
  • Connection with the specified Id not found
  • Empty or invalid Export Path
  • Invalid SQL query
  • Database connection issues
  • Insufficient permissions to write to the export file
  • Transaction with the specified Id not found (if Transaction Id is provided)

Usage Notes

  • The SQL Export field supports template variables using double curly braces (e.g., {{variableName}})
  • Template variables are populated from the message data
  • The exported file will include column headers as the first row
  • If a Transaction Id is provided, the query will be executed within that transaction
  • The separator option determines how values are separated in the exported file
  • The exported file format is CSV-like but with configurable separators
  • Ensure the directory in the export path exists before running the node