---
title: "ezgh warehouse query"
description: "Run one SQL statement."
---

> Documentation Index
> Fetch the complete documentation index at: https://docs.ezghcloud.com/llms.txt
> Use this file to discover all available pages before exploring further.

# ezgh warehouse query

{/* Generated by ezgh-cli's internal/tools/clidocs from the ezgh command tree. Don't edit: change the command's help in ezgh-cli and regenerate. */}

```sh
ezgh warehouse query <warehouse> (-e <sql> | --file f) [--user app] [--database default] [--password-stdin] [flags]
```

Run one SQL statement as one of the warehouse's users and print its result. The user's password is typed at the prompt (it isn't shown) or, with `--password-stdin`, read from stdin; there is no password flag, since arguments end up in shell history. The statement comes from -e or `--file`.

Results stop at 10,000 rows or 16 MiB, and ezgh says so on stderr. A statement runs for at most 5 minutes; Ctrl-C cancels it. Needs warehouse.warehouses.query.

Part of [`ezgh warehouse`](/cli/reference/warehouse).

## Examples

```sh
ezgh warehouse query analytics -e 'SELECT count() FROM events.page_views'
ezgh secrets read sec_… --field password --format raw | ezgh warehouse query analytics --password-stdin --file report.sql -o json
```

## Flags

| Flag | Type | Default | Description |
| --- | --- | --- | --- |
| `--database` | string | `default` | the database it runs in |
| `-e`, `--execute` | string |  | the SQL statement |
| `--file` | string |  | a file holding the SQL statement |
| `--password-stdin` | boolean |  | read the user's password from stdin |
| `--user` | string | `app` | the warehouse user to run it as |

This command also takes the [global flags](/cli/reference#global-flags).

Source: https://docs.ezghcloud.com/cli/reference/warehouse-query/index.mdx
