SQL Querying Agents With Tools
A LangGraph-powered AI agent that lets you query a SQLite database using plain English. No SQL knowledge required — just ask a question and the agent writes and executes the query for you.
How It Works
User Question
|
v
Agent <-----> Tools (get_schema, execute_sql)
|
v
Final Answer
The agent first fetches the database schema, then writes and executes the appropriate SQL query, and returns the result in plain English.
Features
- Natural language to SQL — no query writing needed
- Live SQL execution against a real SQLite database
- Streaming step-by-step agent output
- Example questions in the sidebar to get started quickly
- Clean Streamlit web UI
Live Demo
Local Setup
git clone https://github.com/Ishaan20072612/SQL-Querying-Agents-With-Tools.git
cd SQL-Querying-Agents-With-Tools
pip install -r requirements.txt
streamlit run sql_app.py
Sample Database
Users (5 rows): id, name, email, signup_date
Orders (4 rows): id, user_id, amount, status, order_date
Example questions you can ask:
- How many users have not placed any orders?
- What is the total revenue from completed orders?
- Which user has spent the most?
- Show all pending orders with user names.
Tech Stack
| Library | Purpose |
|---|---|
langchain-core |
Tool definitions |
langchain-openai |
GPT-4o-mini |
langgraph |
Agent graph orchestration |
streamlit |
Web UI |
Project Structure
├── sql_app.py # Streamlit UI
├── sql_agents.py # Core agent logic
├── requirements.txt # Dependencies
└── README.md
Author
Ishaan Chowdhury · @Ishaan20072612
Log in or sign up for Devpost to join the conversation.