workflows.fit
Back to n8n workflows
n8n templateFreeBy Leonardo Grigorio

Query Google Sheets/CSV data through an AI agent using PostgreSQL

Want to see it in action? Watch the full breakdown here: [📺 Video Link](https://www.youtube.com/watch?v=ujXpLSMRmk) Template Description This n8n workflow empowers you to query structured financial data from Google S...

Data & StorageProductivityDevelopmentCore NodesAILangchainCodeGoogle Drive Trigger
Loading interactive preview...

Template notes

Want to see it in action? Watch the full breakdown here: [📺 Video Link](https://www.youtube.com/watch?v=ujXpLSMRmk)

Template Description This n8n workflow empowers you to query structured financial data from Google Sheets or CSV files using AI-generated SQL. Unlike traditional vector database solutions that falter with numerical queries, this template leverages PostgreSQL for efficient data storage and an AI agent to dynamically create optimized SQL queries from natural language inputs.

What It Does - Retrieves data from Google Sheets or CSV files - Infers the data schema and builds a PostgreSQL table - Populates the table with your data - Uses an AI agent to translate natural language questions into SQL queries - Returns precise numerical results quickly and efficiently

Why Use This? - No SQL knowledge required—the AI generates queries for you - Bypasses the inefficiencies and costs of vector database approaches - Scales effortlessly without overwhelming the language model - Fully free and open-source

---

Setup Requirements

Pre-Conditions - PostgreSQL Database: A running PostgreSQL instance (no specific extensions required beyond standard installation). - Google Sheets Access: A publicly accessible or shared Google Sheet URL with structured data (e.g., financial records). Need a starting point? Use this [Sample Google Sheet Template](insert-link-here). - n8n Instance: A working n8n setup with access to the Google Drive and PostgreSQL nodes.

Step-by-Step Instructions 1. Add Your Google Sheets URL - Open the "Google Drive Trigger" node. - Replace the placeholder URL with your Google Sheet’s link. - Verify the sheet name matches your data source.