Reference · Tools

CrateDB

Execute SQL queries, insert rows, and update rows in CrateDB distributed databases using parameterized queries.

Action Data & Storage v1

The CrateDB node lets you execute arbitrary SQL, insert new rows, and update existing records in a CrateDB distributed database — all from within an automated workflow. Use it to pipe sensor readings into a time-series table, sync application data, or query results for downstream processing. Connections use the PostgreSQL wire protocol with CrateDB API credentials.

Node type
Action
Parameters
12
Outputs
Output, Error
Credentials
CrateDB

CrateDB

Execute SQL queries, insert, and update data in CrateDB distributed databases with parameterized queries.

Overview

CrateDB distributed SQL database tool. Supports three operations: Execute Query (run arbitrary SQL with parameterized $1, $2 placeholders), Insert (add rows from input item properties), and Update (modify rows matched by key columns). CrateDB uses the PostgreSQL wire protocol and is accessed via the pg driver. Important: CrateDB does NOT support multi-row UPDATE syntax, so updates are issued as individual statements per item. Default schema is “doc” (not “public” as in PostgreSQL). All queries use parameterized values to prevent SQL injection.

Category: Data & Storage
Tool Name: cratedb
Version: 1

Appearance: Icon: lucide-Database | Color: #009DC7

Node Type

Action — processes input items and produces output

Input / Output

DirectionPort(s)
InputInput
OutputOutput, Error

Credentials

This tool requires CrateDB credentials. See the Credentials Guide for setup instructions.

Operations

OperationValueDescription
Execute QueryexecuteQueryExecute an SQL query
InsertinsertInsert rows in database
UpdateupdateUpdate rows in database

Parameters

Execute Query (executeQuery)

ParameterTypeRequiredDefaultDescription
QuerystringYesThe SQL query to execute. Use $1, $2, etc. for parameterized values (set via Additional Fields > Query Parameters). NEVER concatenate user input directly into the query.

Insert (insert)

ParameterTypeRequiredDefaultDescription
SchemastringYesdocName of the schema the table belongs to. CrateDB default schema is “doc”.
TablestringYesName of the table to insert data into.
ColumnsstringNoComma-separated list of property names from the input item to use as columns for the new rows. Leave empty to use all input item properties.
Return FieldsstringNo*Comma-separated list of fields to return in the RETURNING clause, or ”*” for all fields.

Update (update)

ParameterTypeRequiredDefaultDescription
SchemastringYesdocName of the schema the table belongs to. CrateDB default schema is “doc”.
TablestringYesName of the table to update data in.
Update KeystringYesidComma-separated list of column names to use for matching rows (WHERE clause). Normally “id”.
ColumnsstringNoComma-separated list of property names from the input item to use as columns to update. Leave empty to update all input item properties except the update key(s).
Return FieldsstringNo*Comma-separated list of fields to return in the RETURNING clause, or ”*” for all fields.

All Operations

ParameterTypeRequiredDefaultDescription
Additional FieldscollectionNo{}Optional settings for how the statement is sent.
— ModeoptionsNomultipleThe way queries should be sent to the database.
Options: independently (execute each query independently), multiple (default — sends multiple queries at once to database)
— Query ParametersstringNoComma-separated list of property names from the input item to use as positional query parameters ($1, $2, etc.). (shown when Operation is executeQuery)
Max ConcurrencynumberNo10Maximum number of items to process concurrently. Accepts 1–100.

Output Data

Each returned row becomes its own output item, and the row replaces the item JSON — the columns arrive at the top level, and the properties the item carried in are not preserved. Binary data on the input item is forwarded.

OperationOutput
executeQueryFans out — one item per row the query returned. A statement that returns no rows and is not a SELECT produces one item carrying success: true and rowCount.
insertOne item per input item, carrying the columns named in Return Fields for the inserted row. With no RETURNING output the item carries success: true.
updateOne item per input item, carrying the columns named in Return Fields for the updated row. With no RETURNING output the item carries success: true.

A SELECT that matches nothing still emits one item — the input item with an empty _queryResult array added — so the branch never goes silent:

{
  "_queryResult": []
}

Reference columns downstream by name, e.g. {{ $json.id }} or {{ $json.rowCount }}.

Usage Examples

  • Execute a SQL query against CrateDB with parameterized placeholders
  • Insert rows into a CrateDB table from input item properties
  • Update rows in a CrateDB table matched by key columns
  • Query time-series data from CrateDB with WHERE filters
  • Bulk insert sensor data into CrateDB

Example Configuration

Run a parameterized SELECT. Query Parameters names the item properties whose values fill $1 and $2 — never paste values into the SQL:

{
  "type": "cratedb",
  "parameters": {
    "operation": "executeQuery",
    "query": "SELECT id, name, price FROM doc.product WHERE quantity > $1 AND price <= $2",
    "additionalFields": {
      "queryParams": "minQuantity,maxPrice"
    }
  }
}

Query a time range in a time-series table:

{
  "type": "cratedb",
  "parameters": {
    "operation": "executeQuery",
    "query": "SELECT device_id, avg(temperature) AS avg_temp FROM doc.readings WHERE ts >= $1 AND ts < $2 GROUP BY device_id",
    "additionalFields": {
      "queryParams": "windowStart,windowEnd"
    }
  }
}

Insert named columns from each input item:

{
  "type": "cratedb",
  "parameters": {
    "operation": "insert",
    "schema": "doc",
    "table": "events",
    "columns": "id,name,description",
    "returnFields": "*"
  }
}

Insert every property the item carries:

{
  "type": "cratedb",
  "parameters": {
    "operation": "insert",
    "schema": "doc",
    "table": "sensor_data",
    "columns": "",
    "returnFields": "id"
  }
}

Update rows matched on id, writing only two columns:

{
  "type": "cratedb",
  "parameters": {
    "operation": "update",
    "schema": "doc",
    "table": "devices",
    "updateKey": "id",
    "columns": "name,description",
    "returnFields": "*"
  }
}

Match on a composite key and update everything else on the item:

{
  "type": "cratedb",
  "parameters": {
    "operation": "update",
    "schema": "doc",
    "table": "readings",
    "updateKey": "device_id,ts",
    "columns": "",
    "returnFields": "device_id,ts"
  }
}

Error Handling

ModeBehavior
stopHalts workflow on first error
continueSkips failed items, passes successful ones through
errorPortRoutes failed items to Error output port

Tips

Execute SQL queries, insert rows, and update rows in CrateDB distributed databases. CrateDB uses the PostgreSQL wire protocol with default schema “doc”.

Frequently asked questions

CrateDB uses a 'doc' schema by default — does this node handle that automatically?

You need to be aware of it yourself. CrateDB's default schema is 'doc', not 'public' as in standard PostgreSQL. If you reference a table without a schema prefix (e.g. SELECT * FROM my_table), CrateDB resolves it to doc.my_table. If your table lives in a different schema, qualify it explicitly in your SQL.

How do I pass dynamic values into a query without risking SQL injection?

Use parameterized placeholders. In the Execute Query operation, write your SQL with $1, $2, $3, etc. positional placeholders and supply the corresponding values separately. The node passes them as parameters via the pg driver, so values are never interpolated directly into the query string.

Does the Update operation update multiple rows in a single statement?

No — CrateDB does not support multi-row UPDATE syntax, so the node issues one UPDATE statement per input item. If you're updating 500 rows, expect 500 individual statements to be executed. Plan accordingly if you're working at high volume.

What credentials do I need to connect, and is it the same as a standard PostgreSQL connection?

You'll configure a CrateDB credential (crateDbApi) specifically for this node. CrateDB uses the PostgreSQL wire protocol under the hood, but you should use the dedicated CrateDB credential type rather than a generic PostgreSQL one, since connection defaults like the schema differ between the two.

What happens when a query fails — does the whole workflow stop?

The node has two separate outputs: Output and Error. A failed query routes to the Error output rather than throwing and halting everything, which means you can connect error-handling logic (logging, alerts, retries) directly without wrapping the node in a separate error handler.

Build with the CrateDB node

Drop it into a workflow, wire it to an agent, or call it on a schedule. You'll need CrateDB credentials first.

Open BusyBot

Last updated . Spotted something wrong? Tell us.