query
Preview
This feature is in preview and is subject to change.
Execute a SQL query against MotherDuck and write results to stdout.
Usage
motherduck query [options] [sql]
Arguments
| Argument | Description |
|---|---|
sql | The statement to run. Omit it when reading from --file |
Options
| Option | Description |
|---|---|
--file <path> | Read SQL from a file |
--timeout <seconds> | Query timeout in seconds. Defaults to 120 |
Examples
motherduck query "SELECT count(*) FROM sample_data.nyc.taxi"
motherduck query --file monthly_report.sql
motherduck query --file backfill.sql --timeout 600
motherduck query "SELECT * FROM sample_data.nyc.taxi LIMIT 100" -o csv > trips.csv
motherduck query "SELECT * FROM sample_data.nyc.taxi LIMIT 100" -o json | jq '.[0]'
Related
- Quickstart walks through querying and reading JSON output
- Working with agents