Headless script execution

Run a multi-statement SQL script non-interactively with explicit credentials and a named profile. Exit code drives CI pass/fail.

Category: automation

Syntax

delta-forge-cli --profile <env> --username <u> --password <p> run <FILE>

Description

## Overview Headless execution is the canonical pattern for invoking DeltaForge from cron jobs, build servers, and orchestration systems. A named profile supplies the control-plane URL, explicit `--username` and `--password` (or environment-resolved equivalents) supply credentials, and `run <FILE>` consumes a `.sql` file from disk. No interactive prompts fire; the process returns an exit code and writes result data to stdout. ## Recipe ```bash #!/usr/bin/env bash set -euo pipefail # Credentials come from the CI secret store, not the profile file export DF_PASSWORD="$CI_DB_PASSWORD" delta-forge-cli \ --profile prod \ --username svc-migrator \ run migrations/${GIT_SHA}.sql \ -D run_id="$CI_PIPELINE_ID" \ -D env=prod ``` The script fails fast on any non-zero exit because of `set -e`. A passing run returns 0; a SQL or auth failure returns 1; a client initialisation failure (bad URL, transport failure) returns 2. ## Behavior - The profile is resolved from `~/.config/delta-forge-cli/profiles.toml` (or the platform-specific equivalent). `--username` and `--password` override any values stored in the profile. - `run` has no implicit transaction. A failure on statement N leaves statements 1 through N-1 committed. - Progress lines are written to stderr; result data (tables, JSON) is written to stdout. Redirect the two streams separately if you need them. - Variable substitution via `-D KEY=VALUE` is purely textual. Values are not SQL-escaped.

Examples

# CI job step:
DF_PASSWORD=$CI_SECRET delta-forge-cli --profile prod run migrations/$SHA.sql
delta-forge-cli --profile prod --username svc --password $PASS run nightly/etl.sql
# Inject per-run variables from environment:
delta-forge-cli --profile prod run etl/load.sql -D run_date=$(date -u +%F) -D tenant=$TENANT

Pitfalls

See Also

Open in interactive docs →   DeltaForge home →