Getting Started
Make sure to first set up your PlanetScale developer environment. Once you’ve installed thepscale CLI, you can interact with PlanetScale and manage your databases straight from the command line.
The sql command
Execute a single SQL query against a database branch without an interactive shell. Intended for agents and scripts. For interactive sessions, use pscale shell instead.
Requires
pscale 0.292.0 or later.--org is required.
Available flags
Unlike
pscale shell, the default --role is reader. Pass --role admin (or writer / readwriter) for writes.
Destructive SQL
Queries containingDELETE, DROP, or TRUNCATE as statement keywords are blocked unless --force is passed.
With --format json, blocked queries return "status": "action_required" and "query_kind": "destructive". Agents must ask the user to approve, then re-run with --force. Never use --force without explicit user approval.
JSON output
Use--format json for automation.
Success: status, database, branch, kind (mysql or postgresql), role, row_count, columns, rows; replica when --replica was used.
Errors: one JSON object on stdout with status: "error", error, and next_steps.
Destructive guard: status: "action_required", query_kind: "destructive", issues, and next_steps (includes a --force retry command).

