> ## Documentation Index
> Fetch the complete documentation index at: https://learn.workflow.dog/llms.txt
> Use this file to discover all available pages before exploring further.

# Run Query

> Execute a parameterized SQL query on PostgreSQL.

**Run Query** connects to a PostgreSQL account, executes one SQL statement, and
returns its result rows and affected-row count.

## Inputs

| Input                   | Type               | Required | Description                                                        |
| ----------------------- | ------------------ | -------- | ------------------------------------------------------------------ |
| **Third-party account** | PostgreSQL account | Yes      | Host, database, credentials, port, and SSL settings.               |
| **Query**               | String             | Yes      | A non-empty SQL statement.                                         |
| **Parameters**          | List of any values | No       | Values bound to `$1`, `$2`, `$3`, and later placeholders in order. |

```sql theme={null}
select id, email
from customers
where plan = $1 and created_at >= $2
order by created_at desc;
```

Add `pro` as parameter 1 and the cutoff date as parameter 2.

<Warning>
  Use parameters for values instead of joining untrusted text into SQL.
  Parameter placeholders protect values, but they cannot stand in for table or
  column names.
</Warning>

## Outputs

| Output        | Type            | Description                                                        |
| ------------- | --------------- | ------------------------------------------------------------------ |
| **Rows**      | List of objects | Rows returned by the query. Each object uses column names as keys. |
| **Row Count** | Number          | The number of rows returned or affected.                           |

The database connection is closed after the query succeeds or fails.
