ClickHouse icon

ClickHouse

Query and ingest data into ClickHouse

Actions2

Overview

This node allows you to interact with a ClickHouse database by executing SQL queries or inserting data into tables. It is useful for scenarios where you need to retrieve data from ClickHouse using custom SQL queries or push data into ClickHouse tables directly from your workflows.

Practical examples include:

  • Running complex SELECT queries to fetch analytics or reporting data.
  • Inserting processed data or event logs into ClickHouse for storage and further analysis.

Properties

Name Meaning
Operation Choose between "Query" (execute an SQL query) or "Insert" (insert rows into a table).
Query The SQL query string to execute when the "Query" operation is selected. Supports n8n expressions and ClickHouse query parameters. Example: SELECT id, name FROM product WHERE quantity > {quantity:Int32} AND price <= {price:Int32}. Required for the "Query" operation.
Table name The target table name for inserting data when the "Insert" operation is selected. Supports n8n expressions. Required for the "Insert" operation.

Output

  • For the Query operation, the output is an array of JSON objects representing each row returned by the SQL query. Each item in the output contains a json field with the row data as key-value pairs.
  • For the Insert operation, there is no direct output data; the node completes after inserting the provided rows into the specified table.
  • The node does not output binary data.

Dependencies

  • Requires access to a ClickHouse database instance.
  • Requires credentials including host URL, database name, username, and password to connect to ClickHouse.
  • Uses the official ClickHouse client library (@clickhouse/client) for communication.
  • The node expects proper configuration of these credentials within n8n.

Troubleshooting

  • Connection errors: If the node fails to connect, verify that the ClickHouse server URL, database, username, and password are correct and accessible from the n8n environment.
  • Query syntax errors: Invalid SQL queries will cause errors. Ensure the query syntax matches ClickHouse SQL dialect and that any parameters used are correctly formatted.
  • Insert failures: When inserting data, ensure the input JSON structure matches the target table schema. Mismatched columns or data types can cause insertion errors.
  • Empty results: A query returning no rows will result in an empty output array; verify the query conditions and data availability.
  • Credential test failure: Use the built-in credential test feature to confirm connectivity before running workflows.

Links and References

Discussion