Back to Browse

How to Build an AI SQL Agent with LangChain (NL → SQL)

2.1K views
Jan 4, 2026
51:42

⬇️ Click here to learn how to land a high paying data engineering role NOW ⬇️ https://dataengineerinterviews.com/optin-yt-org?el=snowflake_1hr&htrafficsource=ytorganic Build an AI-powered SQL agent using Langchain and OpenAI that can answer complex database questions automatically. Perfect for data engineers taking AI-focused data engineering courses or building intelligent analytics tools that combine LLMs with traditional data infrastructure. If you're enrolled in a data engineering course exploring AI agents, want to automate SQL query generation, or need to understand how LLMs can interact with databases, this hands-on tutorial shows you how to build a production-ready SQL agent that understands your data schema and writes queries for you. Why this project matters for data engineering courses: AI agents represent the future of data engineering—automating complex SQL queries, understanding schemas, and answering business questions without manual query writing. This bridges traditional data engineering with cutting-edge AI, a skill combination that's increasingly valuable for data engineering course graduates in 2025. More Resources: - Learn Snowflake in 2 Hours: https://youtu.be/mP3QbYURT9k?si=722dm-5hvWFeOqnB - How to Ace the Data Modeling Interview: https://youtu.be/YFVhC3SK0A0?si=YGLS3wjYHhdwYpVA - Don't Get Replaced by AI: https://youtu.be/hMZrHIJshFU?si=aX7NeTxohBLHNZ3j If you’re new to my channel, my name is Christopher Garzon. I run the top Data Engineering Academy in the country, where we help students transition into data engineering from other data professions to increase their compensation. How I got here… At 18 years old, I started at Boston College. At 20, I was sneaking into graduate-level classes to take machine learning and data science courses. At 21, I invested in a data science course from a mentor and wired him $3,000 without ever meeting him. At 22, I landed my first job as a data analyst at Amazon, making $60,000 per year. At 24, I became a data engineer at Amazon, increasing my salary to $100,000 and started angel investing in a couple of data companies. At 25, I moved to a startup as a data engineer and doubled my income to $200,000 per year. At 26, I was making about $350,000 at Lyft. At 27, Lyft stocks went up, and my total compensation reached around $450,000. That same year, I launched the Data Engineering Academy. For the last two and a half years, I’ve been running the Data Engineering Academy full-time, helping thousands of people transition into data engineering and significantly increase their earning potential. To all the data professionals grinding—your journey is still being written. The bigger the obstacles, the greater the story. Remember, don’t settle for your next job. Go for a better one. Chris 00:01:07 - Introduction to AI Agents for Data Engineers 00:03:59 - Goal: Build SQL Agent with Langchain and OpenAI 00:05:58 - Required Packages Setup 00:06:54 - PostgreSQL Connection in .env File 00:09:14 - Getting OpenAI API Key 00:11:35 - Setting Up PostgreSQL Connection 00:23:06 - Understanding LLM Tools 00:25:52 - SQL Database Toolkit Tools Overview 00:30:46 - Available Tools: Query, Schema, List Tables, Query Checker 00:33:41 - Building the SQL Agent 00:35:40 - Testing: "Total Profit by Category" Question 00:38:51 - Reviewing Agent's Thought Process (Question 1) 00:41:59 - Testing Complex Question: "Customers in Common Between Regions" 00:43:04 - Reviewing Agent's Thought Process (Question 2) 00:44:47 - Summary: Reducing Choice Entropy 00:46:41 - Next Session: Video Understanding with Gemini 00:49:03 - Conclusion ⬇️ Click here to learn how to land a high paying data engineering role NOW ⬇️ https://dataengineerinterviews.com/optin-yt-org?el=snowflake_1hr&htrafficsource=ytorganic

Download

1 formats

Video Formats

360pmp477.0 MB

Right-click 'Download' and select 'Save Link As' if the file opens in a new tab.

How to Build an AI SQL Agent with LangChain (NL → SQL) | NatokHD