> 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/es/acciones/workflow-concepts/workflow-steps/logic-steps/sql-query.md).

# Ejecutar consulta SQL

Consulta tu base de datos directamente desde un flujo de trabajo

El paso de consulta SQL te permite ejecutar consultas directamente en tus bases de datos conectadas. Esto puede ser útil para extraer datos en tus flujos de trabajo, o incluso para crear flujos de trabajo centrados en escribir directamente en tus bases de datos.

## Configuración de un paso de "Consulta SQL"

El paso de consulta SQL es bastante sencillo. El único requisito previo es que hayas conectado una base de datos SQL mediante un usuario de solo lectura. Consulta nuestra página de documentación sobre [Conexión de fuentes de datos](/docs/es/contexto/memory-stores/add-data/import-from-sql-database/data-sources.md) para más información.

Una vez que hayas conectado correctamente una fuente de datos, puedes añadir un paso de consulta SQL a tus flujos de trabajo, como se muestra a continuación:

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

Uno de los casos de uso más potentes que hemos visto para nuestro paso de consulta SQL es impulsar un agente que ayude a escribir y editar tus propias consultas. Fue tan popular que construimos nuestra plantilla de agente "Data Sidekick" en torno a él.

A medida que empieces a profundizar más en tus casos de uso, te recomendamos echarle un rápido vistazo entre bastidores:

<figure><img src="https://3036434873-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>Uso de un paso de consulta SQL para impulsar nuestro 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/es/acciones/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.
