> 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 SQL Query permite executar consultas diretamente nas bases de dados ligadas. Isto pode ser útil para obter dados para os seus fluxos de trabalho ou até criar fluxos de trabalho destinados a escrever diretamente nas suas bases de dados.

## Configurar uma etapa «SQL Query»

A etapa SQL Query é bastante simples. O único pré-requisito é ter ligado uma base de dados SQL através de um utilizador com permissões de leitura. Consulte a nossa página de documentação sobre [Ligar fontes de dados](https://docs.airops.com/docs/pt/contexto/knowledge-bases/add-data/import-from-sql-database/data-sources.md) para obter mais informações.

Depois de ligar uma fonte de dados com êxito, pode adicionar uma etapa SQL Query aos seus fluxos de trabalho, como mostrado abaixo:

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

Um dos casos de utilização mais poderosos que encontrámos para a nossa etapa SQL Query é usar um agente para ajudar a escrever e editar as suas próprias consultas. Foi tão popular que criámos o modelo de agente «Data Sidekick» com base nele.

À medida que explora mais a fundo os seus casos de utilização, recomendamos que dê uma vista de olhos rápida aos bastidores:

<figure><img src="https://31915162-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FX2n5yPRPynbnWuO4SH0M%2Fuploads%2Fgit-blob-fc285546ee3b693fb51ce6e6712b54b78b6cc005%2Fsql-step-01-example.png?alt=media" alt="Launch Pricing Analyst Workflow with a SQL Query step that selects launches from the SpaceOps Warehouse, a Run Code step that formats the rows, and a Prompt LLM step that answers the question"><figcaption><p>Uma etapa SQL Query passa linhas para o resto do fluxo de trabalho.</p></figcaption></figure>

## Erros de tempo limite da consulta

Se o conector da base de dados atingir o limite de 300 segundos por pedido, a etapa apresenta **The query timed out after 300 seconds**. Reveja o desempenho da consulta e da base de dados ou reduza a quantidade de dados solicitados antes de tentar novamente. Uma nova tentativa não aumenta o tempo limite do conector.


---

# 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.
