Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.sqlbuild.com/llms.txt

Use this file to discover all available pages before exploring further.

sqb query

Execute ad hoc SQL against the active project connection. Useful for inspecting data, debugging models, or running one-off queries without leaving the SQLBuild CLI.

Usage

sqb --project-dir <path> query "SELECT * FROM dev.fact_orders LIMIT 5"
Or from a file:
sqb --project-dir <path> query --file my_query.sql

Flags

FlagDescription
sqlSQL to execute (positional argument)
--fileRead SQL from a file instead of the command line
--formatOutput format: long (default), table, json, or csv
--limitMaximum rows to return (default: 20)
--no-limitDisable the row limit

Output formats

long (default)

Vertical record format, one field per line:
-[ RECORD 1 ]---------------------------+
order_id | 1
customer_id | 100
status   | completed

-[ RECORD 2 ]---------------------------+
order_id | 2
customer_id | 200
status   | completed

2 rows

table

Horizontal table format:
order_id | customer_id | status
-------- | ----------- | ---------
1        | 100         | completed
2        | 200         | completed

2 rows

json

JSON array of objects:
[{"order_id": 1, "customer_id": 100, "status": "completed"}]

csv

Standard CSV with headers:
order_id,customer_id,status
1,100,completed
2,200,completed

Examples

# Quick inspection with default format
sqb --project-dir examples/waffle_shop query "SELECT * FROM dev.fact_orders"

# Table format with higher limit
sqb --project-dir examples/waffle_shop query "SELECT * FROM dev.dim_customers" --format table --limit 50

# Export to JSON
sqb --project-dir examples/waffle_shop query "SELECT * FROM dev.daily_revenue" --format json --no-limit

# Run SQL from a file
sqb --project-dir examples/waffle_shop query --file debug_query.sql