> 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 SQL Query te permite ejecutar consultas directamente en las bases de datos conectadas. Esto puede resultar útil para incorporar datos a tus flujos de trabajo o incluso para crear flujos enfocados en escribir directamente en tus bases de datos.

## Cómo configurar un paso «SQL Query»

El paso SQL Query es bastante sencillo. El único requisito previo es que hayas conectado una base de datos SQL mediante un usuario con permisos de lectura. Consulta nuestra página de documentación sobre [Conexión de fuentes de datos](https://docs.airops.com/docs/es/contexto/knowledge-bases/add-data/import-from-sql-database/data-sources.md) para obtener más información.

Una vez que hayas conectado correctamente una fuente de datos, puedes añadir un paso SQL Query 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 interesantes que hemos visto para nuestro paso SQL Query es usarlo para que un agente te ayude a escribir y editar tus propias consultas. Tuvo tanto éxito que creamos nuestra plantilla de agente «Data Sidekick» en torno a esta función.

Cuando empieces a profundizar en tus casos de uso, te recomendamos echar un vistazo rápido entre bastidores:

<figure><img src="https://3036434873-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>Un paso SQL Query pasa filas al resto del flujo de trabajo.</p></figcaption></figure>

## Errores por tiempo de espera de la consulta

Si el conector de la base de datos alcanza el límite de 300 segundos por solicitud, el paso muestra **The query timed out after 300 seconds**. Revisa la consulta y el rendimiento de la base de datos, o reduce la cantidad de datos solicitados antes de volver a intentarlo. Volver a intentarlo no aumenta el tiempo de espera del 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/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.
