Skip to main content

ops sling

Sling database operations and queries. Sling is used to query SQL Server (CieTrade, Azure SQL) databases. Results stream directly to the terminal.

Subcommands

SubcommandDescription
testTest database connectivity
queryExecute an ad-hoc SQL query
statusShow database status with table row counts
countCount rows in a table
schemaShow table schema (columns, types)
discoverList tables in a schema
presetRun a preset query by name

Examples

Verify connectivity to all configured Sling targets
Terminal
$ops sling test
List all tables in the cietrade schema
Terminal
$ops sling discover cietrade
Show column names and types for a single table
Terminal
$ops sling schema cietrade.service_records
Get an exact row count for a table
Terminal
$ops sling count cietrade.service_records
Run an ad-hoc SQL query (note: SQL Server requires TOP with ORDER BY)
Terminal
$ops sling query "SELECT TOP 10 * FROM cietrade.accounts"
Database status overview with table row counts
Terminal
$ops sling status
Run a saved preset query by name
Terminal
$ops sling preset daily-summary

SQL Server Caveats

ORDER BY without TOP fails silently

Sling wraps SQL in a subquery before sending it to SQL Server. A bare ORDER BY without TOP N is silently rejected — the query returns exit code 1 with empty results and no error message. Always pair ORDER BY with TOP N when querying SQL Server.

-- ❌ Fails silently on SQL Server
SELECT * FROM cietrade.accounts ORDER BY created_at DESC

-- ✅ Works correctly
SELECT TOP 100 * FROM cietrade.accounts ORDER BY created_at DESC

Common Workflows

🔌

Connectivity Check

Run ops sling test first whenever a query misbehaves — rules out auth and network issues.

🔎

Schema Discovery

ops sling discover + ops sling schema together let you explore an unfamiliar database fast.

📊

Row Audits

ops sling count is the fastest way to verify a sync landed the expected number of rows.

Preset Queries

Frequently-used queries can be saved as presets and invoked via ops sling preset <name>.

Quote Carefully

SQL queries with double quotes, backticks, or $ characters may interact badly with your shell. When in doubt, wrap the query in single quotes or escape carefully.