Ask questions about your data in plain English. The agent writes SQL, executes it, analyzes results with pandas, generates charts, and explains insights — all in one shot.
- 🗣️ Natural language → SQL — powered by GPT-4o with schema-aware prompting
- 🔁 Self-correcting loop — if SQL fails, the agent reads the error and tries again
- 📈 Auto visualization — generates Plotly charts based on query results
- 🧮 Pandas analysis — describes statistics, detects trends, flags anomalies
- 🔌 Multi-DB support — PostgreSQL, MySQL, SQLite, BigQuery, Snowflake
- 💬 Streamlit chat UI — interactive multi-turn conversation with your data
User: "Which product category had the highest revenue last quarter, broken down by month?"
Agent: [analyzes schema] → [writes SQL] → [executes] → [plots bar chart] →
"Electronics led Q4 with $2.4M total revenue. December was the peak month (+31% MoM)
driven by holiday promotions. Laptops alone accounted for 67% of category revenue."
git clone https://github.com/rutvik29/data-analyst-agent
cd data-analyst-agent
pip install -r requirements.txt
cp .env.example .env # add OPENAI_API_KEY + DATABASE_URL
streamlit run ui/app.pyUser Question
│
▼
┌───────────────┐ schema ┌───────────────┐
│ Schema Loader │ ──────────▶ │ SQL Writer │
└───────────────┘ └───────┬───────┘
│ SQL
▼
┌───────────────┐
error ◀── │ Executor │ ──▶ DataFrame
(retry) └───────────────┘
│
┌───────▼───────┐
│ Analyzer │ ──▶ Stats + Insights
└───────┬───────┘
│
┌───────▼───────┐
│ Visualizer │ ──▶ Plotly Chart
└───────────────┘
MIT © Rutvik Trivedi