# SQL Agent + ChatGPT + PostgreSQL

**URL:** <https://community.n8n.io/t/sql-agent-chatgpt-postgresql/56609>\
**Category:** Questions\
**Created:** [October 3, 2024, 1:22pm UTC](https://community.n8n.io/t/sql-agent-chatgpt-postgresql/56609 "2024-10-03T13:22:14Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Marconi\_Medeiros](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/marconi_medeiros/32/45721_2.png) [@Marconi\_Medeiros](https://community.n8n.io/u/Marconi_Medeiros)\
**Post date:** [October 3, 2024, 1:22pm UTC](https://community.n8n.io/t/sql-agent-chatgpt-postgresql/56609/1 "2024-10-03T13:22:14Z")

</div>

I’m having issues with the SQL Agent.

1. I create an AI Agent.
2. I configure it to connect to Postgres, and it returns a successful connection.
3. I connect the “OpenAI Chat Model” as the Model for the SQL Agent.
4. Every time I run the Agent, it returns “I don’t know” to my question.

So, does anyone know how to make the SQL Agent flow work?

---

<div class="post-metadata">

**Author:** ![n8n](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/n8n/32/196425_2.png) [@n8n](https://community.n8n.io/u/n8n)\
**Post date:** [October 3, 2024, 1:22pm UTC](https://community.n8n.io/t/sql-agent-chatgpt-postgresql/56609/2 "2024-10-03T13:22:15Z")

</div>

It looks like your topic is missing some important information. Could you provide the following if applicable.

- **n8n version:**
- **Database (default: SQLite):**
- **n8n EXECUTIONS\_PROCESS setting (default: own, main):**
- **Running n8n via (Docker, npm, n8n cloud, desktop app):**
- **Operating system:**

---

<div class="post-metadata">

**Author:** ![ihortom](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/ihortom/32/11473_2.png) [@ihortom](https://community.n8n.io/u/ihortom)\
**Post date:** [October 3, 2024, 5:26pm UTC](https://community.n8n.io/t/sql-agent-chatgpt-postgresql/56609/3 "2024-10-03T17:26:05Z")

</div>

Welcome to the community @Marconi_Medeiros !

> **Tip for sharing information**
>
> #### Pasting your n8n workflow
> 
> * * *
> 
> Ensure to copy your n8n workflow and paste it in the _code block_, that is in between the pairs of triple backticks, which also could be achieved by clicking `</>` (preformatted text) in the editor and pasting in your workflow.
> 
> ```  
> \<your workflow\>  
> ```
> 
> That implies to any JSON output you would like to share with us.
> 
> * * *

The answer “I don’t know” comes from the default prompt which states

> If the question does not seem related to the database, just return “I don’t know” as the answer.

I believe you are expected to ask questions related to the actual data stored in the database. Can you try to rephrase your question making sure you are asking about data stored in the database table(s)?

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/system/32/195824_2.png) [@system](https://community.n8n.io/u/system)\
**Post date:** [January 1, 2025, 5:26pm UTC](https://community.n8n.io/t/sql-agent-chatgpt-postgresql/56609/4 "2025-01-01T17:26:38Z")

</div>

Closed on January 1, 2025, 5:26pm UTC

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.
