# Database Query
URL: /reference/blocks/system-database-query
Type: reference
Description: Execute SQL queries against your database
Keywords: database query, system/database-query, system, database, block, workflow builder
`system/database-query` — Execute SQL queries against your database.

Where it appears [#where-it-appears]

The **Database Query** block lives in the **Logic & control** group of the Workflow Builder. Connect the Database integration before adding it.

Fields [#fields]

| Field      | Type        | Required | Default | Description                                                                                                                                                                                              |
| ---------- | ----------- | -------- | ------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `dbQuery`  | code        | Yes      | —       | SQL run against the connected database. Use positional placeholders like $1 for parameterized values rather than interpolating untrusted input directly. Returned rows are exposed on the `rows` output. |
| `dbSchema` | JSON schema | No       | —       | Optional declaration of the shape of each returned row, so downstream steps can reference typed fields (under the `rows` prefix). Leave empty to return rows untyped.                                    |

Inputs and outputs [#inputs-and-outputs]

Inputs are the configurable fields above. The block produces these outputs:

**Outputs**

Reference an output downstream with `<Database Query.field>`.

| Name      | Type    | Description             |
| --------- | ------- | ----------------------- |
| `success` | boolean | Whether query succeeded |
| `rows`    | array   | Query result rows       |
| `count`   | number  | Row count               |
| `error`   | string  | Error message if failed |

Example [#example]

A minimal configuration for this block:

```json
{
  "type": "system/database-query",
  "config": {
    "dbQuery": "..."
  }
}
```

Limits and failure modes [#limits-and-failure-modes]

* Requires a connected Database integration. Calls fail if that integration is disconnected or its authorization has expired.
* Required field (`dbQuery`) must be set, or the block fails validation before it runs.
* On failure the `error` output is populated; downstream blocks that reference other outputs may not receive values.

Related [#related]

* [All workflow blocks](/reference/blocks)
* [Workflow Builder overview](/workflow-builder-overview)
* [Integrations](/integrations)