Skip to content

Workflow Introduction

Datus Agent Workflow is an intelligent system that transforms natural language questions into SQL queries and executes them against your databases. Think of it as having a data analyst that understands your business needs and can automatically generate the right SQL queries to get you the answers you need.

Embedded Workflows

Datus Agent offers different embedded workflows for different needs:

1. Fixed Workflow

Best for: General SQL generation and execution

  • Performance: Fast and predictable
  • Perfect for: "List all customers from California" or "Show me total sales for 2023"
  • Use cases: Direct data retrieval, aggregations, filtering, and multi-table queries

2. Agentic Workflows

Best for: Queries that benefit from iterative tool use

  • Tool use: Can search predefined business metrics and other context
  • Perfect for: "Show monthly active users for the last quarter" or "Calculate customer churn rate"
  • Use cases: KPI reporting, temporal analysis, semantic-layer queries, and complex SQL generation

Nodes: The Building Blocks

Workflows are made up of specialized components called "nodes." Each node does one job really well:

Getting Started

Basic Usage

# Ask a simple question
datus-agent run --datasource your_db --task_db_name analytics --task "Show me monthly sales"

# Use a specific workflow type
datus-agent run --datasource your_db --task_db_name analytics --task "Show me complex revenue trends" --workflow fixed

# Use business metrics
datus-agent run --datasource your_db --task_db_name analytics --task "Calculate customer lifetime value" --workflow gen_sql_agentic

Via API

You can also use workflows through a REST API:

import requests

response = requests.post(
    "http://localhost:8000/workflows/run",
    headers={"Authorization": "Bearer your_token"},
    json={
        "workflow": "fixed",
        "datasource": "your_db",
        "task": "Show me quarterly revenue trends",
        "mode": "sync"
    }
)

result = response.json()
print(result["sql"])    # The generated SQL query
print(result["result"]) # The query results

Next Steps