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

# Run SQL Query

Query your database directly from a workflow

The SQL Query Step allows you to run queries directly against your connected databases. This can be useful for pulling data into your workflows, or even building out workflows focused on writing directly to your databases.

## Configuring a "SQL Query" Step

The SQL Query Step is fairly straightforward. The only prerequisite is that you have connected a SQL database via a read user. See our documentation page on [Connecting Datasources](/context/memory-stores/add-data/import-from-sql-database/data-sources.md) for more information.

Once you have successfully connected a data source, you can add a SQL Query Step into your Workflows as shown below:

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

One of the most powerful use-cases we've seen for our SQL Query Step is to power an Agent to assist with writing and editing your own queries. It was so popular, that we built our "Data Sidekick" Agent template around it.

As you start to dig into your use-cases more deeply, we would recommend giving it a quick peek behind the curtains:

<figure><img src="https://3762890407-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>Using a SQL Query Step to power our "Data Sidekick" Agent</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/actions/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.
