@@ -108,6 +108,7 @@ For examples and command-specific options, click through the command in the tabl
108108| [ ` lightdash upload ` ] ( /references/lightdash-cli#lightdash-upload ) | Upload charts and dashboards as code to your Lightdash project |
109109| [ ` lightdash rename ` ] ( /references/lightdash-cli#lightdash-rename ) | Rename model or field names across all your Lightdash content |
110110| [ ` lightdash diagnostics ` ] ( /references/lightdash-cli#lightdash-diagnostics ) | Show diagnostic information about the CLI environment |
111+ | [ ` lightdash sql ` ] ( /references/lightdash-cli#lightdash-sql ) | Run raw SQL query against the warehouse using project credentials |
111112---
112113
113114### ` lightdash login `
@@ -754,6 +755,54 @@ Show diagnostic information with dbt debug for a specific project directory:
754755lightdash diagnostics --dbt --project-dir ./my-dbt-project
755756```
756757
758+ ### ` lightdash sql `
759+
760+ Run a raw SQL query against your data warehouse using the credentials from your currently selected project. Results are exported to a CSV file.
761+
762+ ``` console
763+ lightdash sql <query> -o <output_file>
764+ ```
765+
766+ ** Required argument:**
767+
768+ - ` <query> `
769+ - The SQL query to execute
770+
771+ ** Required option:**
772+
773+ - ` -o, --output <file> `
774+ - Output file path for CSV results
775+
776+ ** Options:**
777+
778+ - ` --limit <number> `
779+ - Maximum number of rows to return from the query
780+ - ` --page-size <number> `
781+ - Number of rows per page (default: 500, max: 5000)
782+ - ` --verbose `
783+ - (default: false)
784+ - Show detailed output
785+
786+ ** Examples:**
787+
788+ Run a simple query and save results to a CSV file:
789+
790+ ``` bash
791+ lightdash sql " SELECT * FROM users LIMIT 100" -o users.csv
792+ ```
793+
794+ Run a query with a row limit:
795+
796+ ``` bash
797+ lightdash sql " SELECT * FROM orders" -o orders.csv --limit 1000
798+ ```
799+
800+ Run a query with verbose output to see detailed progress:
801+
802+ ``` bash
803+ lightdash sql " SELECT customer_id, SUM(amount) FROM orders GROUP BY 1" -o revenue.csv --verbose
804+ ```
805+
757806---
758807
759808## dbt options
0 commit comments