> For the complete documentation index, see [llms.txt](https://docs.airops.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.airops.com/docs/pt/acoes/workflow-concepts/workflow-steps/logic-steps/sql-query.md).

# Executar consulta SQL

Consulte a sua base de dados diretamente a partir de um workflow

A Etapa de Consulta SQL permite executar consultas diretamente nas suas bases de dados ligadas. Isto pode ser útil para trazer dados para os seus fluxos de trabalho, ou até para criar fluxos de trabalho focados em escrever diretamente nas suas bases de dados.

## Configurar uma Etapa de "Consulta SQL"

A Etapa de Consulta SQL é bastante simples. O único pré-requisito é ter ligado uma base de dados SQL através de um utilizador de leitura. Veja a nossa página de documentação sobre [Ligar Fontes de Dados](/docs/pt/contexto/memory-stores/add-data/import-from-sql-database/data-sources.md) para mais informações.

Depois de ter ligado com sucesso uma fonte de dados, pode adicionar uma Etapa de Consulta SQL aos seus fluxos de trabalho, como mostrado abaixo:

{% @arcade/embed url="<https://app.arcade.software/share/10JanDKu9KE0Ahb7n7Fp>" flowId="10JanDKu9KE0Ahb7n7Fp" %}

Um dos casos de uso mais poderosos que vimos para a nossa Etapa de Consulta SQL é alimentar um Agente para ajudar a escrever e editar as suas próprias consultas. Tornou-se tão popular que construímos o nosso modelo de Agente "Data Sidekick" em torno dele.

À medida que começa a explorar os seus casos de uso com mais profundidade, recomendamos que espreite rapidamente os bastidores:

<figure><img src="https://31915162-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FX2n5yPRPynbnWuO4SH0M%2Fuploads%2Fgit-blob-92c24093963ddc7153dd0be3c8da77356686d77e%2Futility_sql_query.png?alt=media" alt=""><figcaption><p>Usar uma Etapa de Consulta SQL para alimentar o nosso Agente "Data Sidekick"</p></figcaption></figure>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.airops.com/docs/pt/acoes/workflow-concepts/workflow-steps/logic-steps/sql-query.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
