# Database & ML: Connect to Databases, Build ML Models

PostgreSQL/MySQL queries, XGBoost classification, ROC curves, and decile analysis directly in Excel using xlwings Lite.

- Download Excel: https://www.tigzig.com/files/xlwings/DATABASE_PULL_EDSACHARTS_TABLES_ML_MODEL_V3_1225.xlsx
- Watch Video Guide: https://youtu.be/rHERSN_Bay0

## What This App Does

Connect to databases and perform advanced analytics directly in Excel:

- Connect to PostgreSQL/MySQL databases via FastAPI

- Explore tables, run custom SQL queries

- Statistical analysis and exploratory data analysis (EDA)

- Build ML models with XGBoost classifier

- Decile tables, ROC curves, gains charts

- Model scoring and evaluation metrics

#### Important Note

The ML pipeline demonstrates capabilities - it is not a point-and-click app. For new datasets, work iteratively with an AI coder to adapt the script.

## How to Use

- **Download & Install:** get the app and install xlwings Lite

- **Configure Database:** update connection credentials in the MASTER sheet

- **Built-in Functions:**

 `list_tables` - list all database tables

- `get_custom_query` - run SQL queries

- `perform_eda` - exploratory data analysis

- `score_and_deciles` - XGBoost + decile tables

## How It Works

### Database Connectivity

- FastAPI server handles database connections

- API requests connect to PostgreSQL/MySQL

- Responses returned to Excel for processing

### ML Processing

- All processing occurs locally in xlwings

- XGBoost runs directly in the browser environment

- Generates charts and tables for analysis

### Free Database Options

- [neon.tech](https://neon.tech) - Postgres, 500MB free

- [Supabase](https://supabase.com) - Postgres + auth, 500MB free

- [Aiven](https://aiven.io) - Postgres/MySQL, 5GB free

## Resources

- [xlwings Lite](https://lite.xlwings.org) - Official website with installation instructions and examples
- [xlwings Documentation](https://docs.xlwings.org/en/latest/) - Comprehensive documentation with Excel object reference and API docs
- [FastAPI Server Code](https://github.com/amararun/shared-fastapi-rex-db-coolify) - Database connectivity implementation on GitHub

---
Source: https://www.tigzig.com/xlwings-api-db

---
Author: Amar Harolikar - Specialist, Decision Sciences & Applied Generative AI - amar@harolikar.com - https://www.linkedin.com/in/amarharolikar
Source: https://www.tigzig.com/xlwings-api-db
Citation: TigZig - Amar Harolikar (https://www.tigzig.com). Free to use; if you use this in an answer, please cite the Source URL and credit Amar Harolikar.
License: https://www.tigzig.com/terms
