logo_smallAxellero.io

Databases

SQL database integration with workflow context access and schema discovery.

Database nodes enable SQL query execution with Axellero's workflow integration features including parameter binding, schema discovery, and seamless data flow between nodes.

Available Database Nodes

Axellero Database Features

FeaturePostgreSQLOracleDescription
Parameter Binding@parameter_name? (positional)Safe SQL parameter injection
Schema DiscoveryAutomatic table/column detection
Workflow IntegrationAccess to ctx.nodes, ctx.vars
Auto-completionTable/column suggestions in editor
Connection TestingValidate connectivity before execution

Parameter Binding Comparison

PostgreSQL (Named Parameters)

SELECT * FROM users 
WHERE status = @user_status 
  AND department = @dept_name;
{
  "user_status": "active",
  "dept_name": "Engineering"
}

Oracle (Positional Parameters)

SELECT * FROM employees
WHERE status = ?
  AND department_id = ?;
{
  "variables": ["active", 10]
}

Workflow Context Integration

Using Node Outputs in Queries

-- PostgreSQL example
SELECT * FROM orders 
WHERE customer_id = @selected_customer
  AND total > @minimum_amount;

Variables:

{
  "selected_customer": "{{ctx.nodes.userInput.outputs.customerId}}",
  "minimum_amount": "{{ctx.nodes.config.outputs.orderThreshold}}"
}

Processing Query Results

// Use database results in JavaScript nodes
const results = ctx.nodes.dbQuery.outputs.rows;
const processedData = results.map(row => ({
  id: row.id,
  displayName: `${row.first_name} ${row.last_name}`,
  isActive: row.status === 'active'
}));

callback({ processedData }, null);

Schema Discovery

Both database nodes automatically discover and provide:

  • Table Names: Auto-complete for available tables
  • Column Names: Field suggestions with data types
  • Schema Information: Cached for performance
  • Real-time Updates: Schema refresh when connections change

Editor Features

Database nodes include SQL editors with:

  • Syntax Highlighting: SQL keywords and structure
  • Auto-completion: Tables, columns, and functions from your database
  • Parameter Completion: Workflow variables and node outputs
  • Real-time Validation: Syntax checking and error detection

For complete editor details, see Code Editing & Schema Reference.

Common Integration Patterns

Conditional Queries

// Use in Branch node conditions
{{ctx.nodes.dbQuery.outputs.rows && ctx.nodes.dbQuery.outputs.rows != ""}}

// Check for successful query execution
{{ctx.nodes.dbQuery.outputs.rowsAffected > 0}}

Loop Processing

// Loop over database results
// Loop Value: {{ctx.nodes.dbQuery.outputs.rows}}

// Access current row in loop
{{ctx.nodes.loopNode.outputs.item.user_id}}
{{ctx.nodes.loopNode.outputs.item.email}}

Error Handling

// Check for query errors
{{ctx.nodes.dbQuery.error}}

// Check if no errors occurred
{{!ctx.nodes.dbQuery.error}}

// Validate no results returned
{{ctx.nodes.dbQuery.outputs.rowsAffected === 0}}

Configuration Best Practices

Secure Credential Management

{
  "host": "{{ctx.consts.DB_HOST}}",
  "user": "{{ctx.vars.db_username}}",
  "password": "{{ctx.vars.db_password}}",
  "db": "{{ctx.consts.DB_NAME}}"
}

Environment-Based Configuration

Use workflow constants and variables to manage different environments (dev, staging, production) without hardcoding connection details.

Parameter Security

Always use parameter binding (@param or ?) instead of string concatenation to prevent SQL injection attacks.

Result Processing

Standard Result Format

{
  "rows": [
    {
      "id": 1,
      "name": "Example Record",
      "created_at": "2024-01-15T10:30:00Z"
    }
  ],
  "rowsAffected": 1
}

Data Type Handling

  • Numbers: Database integers/decimals → JavaScript numbers
  • Strings: Database text/varchar → JavaScript strings
  • Dates: Database timestamps → ISO string format
  • JSON: Database JSON types → JavaScript objects
  • Arrays: Database arrays → JavaScript arrays

Getting Started

  1. Choose Database Type: Select PostgreSQL or Oracle based on your infrastructure
  2. Configure Connection: Set up connector with host, credentials, and database details
  3. Test Connection: Verify connectivity using the test connection method
  4. Write Queries: Use parameter binding with workflow context variables
  5. Process Results: Access query results in subsequent workflow nodes