Cloudflare Query

Cloudflare Query

Certified

Run a SQL statement against a Cloudflare D1 database

Executes a parameterized SQL statement against a D1 database. Supports four fetch modes: FETCH_ONE returns the first row as a map, FETCH returns all rows as a list of maps, STORE writes all rows to Kestra internal storage as a newline-delimited ION file, and NONE returns only the query metadata (rows written, duration).

yaml
type: io.kestra.plugin.cloudflare.d1.Query

Run a SELECT and store results in Kestra storage

yaml
id: d1_query_store
namespace: company.team

tasks:
  - id: query
    type: io.kestra.plugin.cloudflare.d1.Query
    apiToken: "{{ secret('CLOUDFLARE_API_TOKEN') }}"
    accountId: "your_account_id"
    databaseId: "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
    sql: "SELECT id, name FROM users WHERE active = ?"
    params:
      - true
    fetchType: STORE

Insert a row and capture metadata

yaml
id: d1_query_insert
namespace: company.team

tasks:
  - id: insert
    type: io.kestra.plugin.cloudflare.d1.Query
    apiToken: "{{ secret('CLOUDFLARE_API_TOKEN') }}"
    accountId: "your_account_id"
    databaseId: "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
    sql: "INSERT INTO events (name, ts) VALUES (?, ?)"
    params:
      - "deploy"
      - "2024-01-01T00:00:00Z"
    fetchType: NONE
Properties

Account ID

Cloudflare account identifier

Cloudflare API token

Your Cloudflare API token. Create one in the Cloudflare dashboard with the permissions required by the resources you manage (e.g. DNS, Workers, Workers AI, D1, cache, WAF, zones).

Database ID

UUID of the D1 database to query

SQL statement

Parameterized SQL statement to execute; use ? as positional placeholders

Assets this task consumes as inputs or produces as outputs, for lineage tracking and the asset graph (Enterprise Edition). A flow declaring this property on a task is rejected in the open-source edition.

Definitions
assetFailureBehaviorstring
Possible Values
IGNOREFAILWARN

Asset failure behavior

Behavior applied to the task state when a declared asset fails to render, emit, or be persisted (e.g. a lock conflict): FAIL escalates it to FAILED, WARN (default) warns it if it would otherwise succeed, IGNORE leaves the state untouched.

enableAutobooleanstring

Whether to auto-register assets referenced dynamically at runtime that are not statically declared in inputs or outputs.

inputsarray

The assets consumed as inputs.

id*string
Min length1
typestring
outputs

The assets produced as outputs.

id*string
Min length1
Max length150
type*object
descriptionstring
displayNamestring
metadataobject
Default{}
namespacestring
Min length1
Max length150
id*string
Min length1
Max length150
type*object
descriptionstring
displayNamestring
metadataobject
Default{}
namespacestring
Min length1
Max length150
id*string
Min length1
Max length150
type*object
descriptionstring
displayNamestring
metadataobject
Default{}
namespacestring
Min length1
Max length150
id*string
Min length1
Max length150
type*object
descriptionstring
displayNamestring
metadataobject
Default{}
namespacestring
Min length1
Max length150
id*string
Min length1
Max length150
type*object
descriptionstring
displayNamestring
metadataobject
Default{}
namespacestring
Min length1
Max length150
id*string
Min length1
Max length150
type*string
Min length1

Custom asset type

descriptionstring
displayNamestring
metadataobject
Default{}
namespacestring
Min length1
Max length150
Defaulthttps://api.cloudflare.com/client/v4

Cloudflare API base URL

Base URL for Cloudflare API. Usually you don't need to change this.

DefaultSTORE
Possible Values
FETCH_ONEFETCHSTORENONE

Fetch type

Controls how result rows are returned: FETCH_ONE returns the first row as a map, FETCH returns all rows as a list of maps, STORE writes all rows to Kestra internal storage and returns a URI, NONE returns only query execution metadata.

HTTP client options

Optional advanced HTTP settings like timeouts or proxy.

Definitions
allowFailedbooleanstring
Defaultfalse

If true, allow a failed response code (response code >= 400)

allowedResponseCodesarray
SubTypeinteger

List of response code allowed for this request

auth

The authentication to use.

type*object
passwordstring

The password for HTTP basic authentication.

usernamestring

The username for HTTP basic authentication.

type*object
tokenstring

The token for bearer token authentication.

type*object
passwordstring

The password for HTTP Digest authentication.

usernamestring

The username for HTTP Digest authentication.

defaultCharsetstring
DefaultUTF-8

The default charset for the request.

enabledTcpExtendedKeepAlivebooleanstring
Defaulttrue

Whether to enable TCP Keep-Alive extended socket options (TCP_KEEPIDLE, TCP_KEEPINTERVAL, TCP_KEEPCOUNT).

Set to false when running on Windows workers, as these extended socket options are not supported by the Windows JDK and will cause connection failures.

followRedirectsbooleanstring
Defaulttrue

Whether redirects should be followed automatically.

logsarray
SubTypestring
Possible Values
REQUEST_HEADERSREQUEST_BODYRESPONSE_HEADERSRESPONSE_BODY

The enabled log.

proxy

The proxy configuration.

addressstring

The address of the proxy server.

passwordstring

The password for proxy authentication.

portintegerstring

The port of the proxy server.

typestring
DefaultDIRECT
Possible Values
DIRECTHTTPSOCKS

The type of proxy to use.

usernamestring

The username for proxy authentication.

ssl

The SSL request options

insecureTrustAllCertificatesbooleanstring

Whether to disable checking of the remote SSL certificate.

Only applies if no trust store is configured. Note: This makes the SSL connection insecure and should only be used for testing. If you are using a self-signed certificate, set up a trust store instead.

timeout

The timeout configuration.

connectTimeoutstring

The time allowed to establish a connection to the server before failing.

readIdleTimeoutstring
DefaultPT5M

The time allowed for a read connection to remain idle before closing it.

Query parameters

Ordered list of positional parameter values for the ? placeholders in the SQL statement

Query metadata

Execution metadata returned by D1 (duration, rows read/written, etc.)

Definitions
changedboolean
changesinteger
durationnumber
last_row_idinteger
rows_readinteger
rows_writteninteger

Single row

First result row as a map (FETCH_ONE mode only)

SubTypeobject

All rows

All result rows as a list of maps (FETCH mode only)

Default0

Row count

Number of rows in the result set

Formaturi

Storage URI

Internal storage URI of the newline-delimited ION file (STORE mode only)