Query icon

Query SurrealDB and store the result as a downloadable artifact

Orchestrate SurrealDB queries with Kestra. Insert records, run SurrealQL SELECT statements, and store results as artifacts for downstream tasks.

Categories
Data

Run SurrealQL statements against a SurrealDB instance and persist the results as downloadable artifacts inside Kestra internal storage. This blueprint chains record creation, relational inserts, and SELECT queries to demonstrate how to use SurrealDB as both an operational and analytical data store within a Kestra pipeline. The stored output is referenceable by downstream tasks using the standard {{ outputs.query.uri }} expression, which makes SurrealDB a first class citizen alongside Postgres, Redis, BigQuery, and other engines in your orchestration graph.

How it works

The flow runs four io.kestra.plugin.surrealdb.Query tasks in sequence against the same SurrealDB instance:

  1. article creates an article record with a timestamp, an author reference, body text, and a subquery resolving the parent account.
  2. account creates the ACME Inc account record.
  3. query runs SELECT * FROM article, account with fetchType: STORE, which writes the rowset to Kestra internal storage and exposes its URI as a task output.
  4. query_condition runs a filtered SELECT with a FETCH clause to pull related author and account records, again storing the result as an artifact.

Connection parameters (host, database, namespace, username, password) are centralized via pluginDefaults so every task inherits the same SurrealDB endpoint.

What you get

  • End to end SurrealQL workflow showing inserts, relational links, and reads.
  • Query outputs stored as artifacts you can download or reuse downstream.
  • A reproducible pattern for using SurrealDB inside a multi step pipeline.
  • Centralized connection config through pluginDefaults.

Who it's for

  • Backend and data engineers adopting SurrealDB for graph or document workloads.
  • Platform teams standardizing how application databases are queried from pipelines.
  • Developers prototyping SurrealDB schemas who want repeatable seed and query flows.

Why orchestrate this with Kestra

SurrealDB ships with a powerful query engine but no native scheduler, retry policy, or cross system lineage. Kestra adds declarative YAML, event and schedule triggers, automatic retries on transient failures, full execution history, and the ability to chain SurrealDB queries with HTTP calls, file processing, notifications, or loads into other warehouses. You also get artifact storage out of the box, so query results survive the run and can feed downstream tasks or audits.

Prerequisites

  • A running SurrealDB instance reachable from the Kestra worker.
  • The plugin-surrealdb plugin available in your Kestra installation.

Secrets

This blueprint uses hardcoded development defaults (root / root against localhost). For any non local environment, replace the pluginDefaults values with {{ secret('SURREALDB_HOST') }}, {{ secret('SURREALDB_USERNAME') }}, and {{ secret('SURREALDB_PASSWORD') }}.

Quick start

  1. Install SurrealDB locally following the SurrealDB start guide.
  2. Start SurrealDB on localhost with namespace test and database test.
  3. Copy this blueprint into your Kestra namespace.
  4. Execute the flow and inspect the query and query_condition outputs to download the stored results.

How to extend

  • Add a Schedule or webhook trigger to run the queries on a cadence or on demand.
  • Replace the inline CREATE statements with parameterized inputs to ingest real records.
  • Pipe the stored output into a downstream task that pushes results to S3, BigQuery, or Slack.
  • Wrap each Query with retry policies for resilience against transient connection errors.
  • Split inserts and reads into separate subflows for reuse across pipelines.

Links

Tasks
Share this Blueprint
See How

New to Kestra?

Use blueprints to kickstart your first workflows.