> For the complete documentation index, see [llms.txt](https://docs.zbrain.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.zbrain.ai/zbrain-documentation/zbrain-builder/flows/flow-components/postgres.md).

# Postgres

Integrate your PostgreSQL database with ZBrain Flow to automate data management by executing SQL queries directly within your workflows.

The Postgres piece in ZBrain Flow provides seamless integration with PostgreSQL databases, allowing you to query and manipulate data directly from your workflows. This powerful connector enables you to run SQL queries, retrieve results, and incorporate database operations into your automation processes. With Postgres integration, you can build workflows that access relational data, perform complex data operations, update records, and extract information from your PostgreSQL databases—all without requiring manual intervention or additional coding. This piece is ideal for businesses that store critical information in PostgreSQL and want to incorporate that data into their automated processes.

### **How to Use Postgres in ZBrain Flow?** <a href="#how-to-use-postgres-in-zbrain-flow" id="how-to-use-postgres-in-zbrain-flow"></a>

**Step 1: Select Postgres as Your Connection**

* Click on the '+' button in the Flow and search for Postgres.
* Select Postgres.
* The primary action available is:
  * **Run Query** – Execute SQL statements against your PostgreSQL database.

**Step 2: Configure Your Postgres Connection**

* If this is your first time connecting to PostgreSQL, you'll need to set up a connection:
  * Click on 'Select a connection' and then 'Create connection'
  * Enter a descriptive 'Connection Name'
  * Provide your database 'Host' (server address)
  * Specify the 'Port' (an integer)
  * Enter your database 'User' credentials
  * Provide the 'Password' for authentication
  * Specify the 'Database' name to connect to
  * Configure SSL options if your database requires secure connections
  * Toggle 'Verify server certificate' on to validate the database server's SSL certificate
  * Optionally upload a 'Certificate' if you're using a custom CA for verification
  * Click 'Save' to create the connection

**Step 3: Configure Your SQL Query**

* In the 'Query' field, enter your SQL statement. For security, use parameterized queries with placeholders ($1, $2, etc.) instead of directly inserting dynamic values.
* Add query arguments by clicking 'Add Item' in the 'Arguments' section.

**Step 4: Configure Performance Settings**

* Set 'Query Timeout' to limit the maximum execution time (in milliseconds).
* Adjust 'Connection Timeout' to control how long to wait for a database connection.
* Optionally provide an 'Application Name' to identify your connection in database logs.

<br>


---

# 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.zbrain.ai/zbrain-documentation/zbrain-builder/flows/flow-components/postgres.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.
