ClickHouse icon

ClickHouse

Query and ingest data into ClickHouse

Actions2

Overview

The ClickHouse node for n8n allows you to interact with a ClickHouse database. In the "Query" operation, it executes a user-defined SQL query against the specified ClickHouse instance and returns the results as structured JSON data. This is useful for retrieving data from ClickHouse tables, performing analytics, or integrating ClickHouse data into your automation workflows.

Common scenarios:

  • Fetching product or sales data for reporting.
  • Running analytical queries on large datasets stored in ClickHouse.
  • Integrating ClickHouse query results with other systems via n8n.

Example:
You could use this node to run a query like SELECT id, name FROM product WHERE quantity > 10 AND price <= 100 and process the resulting product list in subsequent workflow steps.


Properties

Name Type Meaning
Query String The SQL query to execute. You can use n8n expressions or ClickHouse query parameters. Required field.

Output

  • The output is an array of objects, each with a json property containing one row from the query result.
  • Each object in the output corresponds to a row returned by the SQL query, with keys matching the column names.

Example output:

[
  {
    "json": {
      "id": 1,
      "name": "Product A"
    }
  },
  {
    "json": {
      "id": 2,
      "name": "Product B"
    }
  }
]
  • No binary data is produced by this operation.

Dependencies

  • External Service: Requires access to a ClickHouse database.
  • Credentials: Needs a configured ClickHouse credential in n8n (with URL, database, username, and password).
  • n8n Configuration: The node must be provided with valid ClickHouse credentials via n8n's credential system.

Troubleshooting

Common issues:

  • Invalid Credentials: If the ClickHouse credentials are incorrect, connection will fail. Ensure the URL, database, username, and password are correct.
  • SQL Syntax Errors: If the query is malformed, ClickHouse will return an error. Double-check your SQL syntax.
  • Network Issues: If n8n cannot reach the ClickHouse server (e.g., due to firewall or network configuration), the node will fail to connect.

Error messages:

  • "Connection successful!" – Connection test passed.
  • "Error: <message>" – Connection failed; check the message for details (e.g., authentication failure, unreachable host).
  • Query execution errors will surface as node errors with details from ClickHouse.

Links and References

Discussion