> ## Documentation Index
> Fetch the complete documentation index at: https://docs.keyflow.space/llms.txt
> Use this file to discover all available pages before exploring further.

# PostgreSQL

## Overview

The PostgreSQL block executes a SQL query on a PostgreSQL database and returns the response.

<Note>
  To run this block, you will first need to add the connection string of your
  PostgreSQL databaseso that it's encrypted and stored securely within Keyflow.
  Navigate to your [credentials](https://keyflow.space/settings/credentials)
  page and connect add connection string to "PostgreSQL" integration
</Note>

### Inputs & Outputs

| I/O    | Feature           | Type   | Simple Explanation                                               |
| ------ | ----------------- | ------ | ---------------------------------------------------------------- |
| input  | `query`           | string | The SQL query you want to run on the PostgreSQL database.        |
| input  | `data` (optional) | object | A set of parameters to format your query dynamically if needed.  |
| output | `query_response`  | string | The JSON string containing the response from the executed query. |

***

### Use Cases

Explore how this block enhances functionality across various applications:

* **Dynamic Reporting:** When generating reports, use this block to run complex SQL queries that aggregate sales data over time, allowing stakeholders to make informed decisions based on real-time insights.
* **User Data Management:** In user-centric services like subscription apps, retrieve specific user profiles or preferences by executing tailored queries, ensuring personalized experiences for users.
* **Data Migration:** During system upgrades or migrations, leverage this block to execute necessary data retrieval operations from old databases before transferring it into new structures.
* **Batch Processing:** For processing large datasets, such as analyzing customer transactions monthly or retrieving logs for error analysis across multiple entries efficiently using batch SQL commands.

In essence, the `PostgreSQL Query Executor` block serves as a powerful tool in managing and manipulating your database interactions effortlessly!
