Connect to Databases, Build ML Models
Connect to APIs and databases, run queries, build Machine Learning models
xlwings Lite: Connect to Databases, Build Machine Learning Models
Excel app demonstrating how to connect to databases, run queries, and perform advanced analytics using xlwings Lite add-in.
How xlwings Lite Works: The Python code is embedded directly inside the Excel file itself! Download the Excel file from the link below to get the complete app with all code included.
What This App Does
This xlwings Lite app enables you to connect to databases and perform advanced analytics directly in Excel:
- Connecting to PostgreSQL/MySQL databases
- Exploring tables and running custom SQL queries
- Pulling and manipulating data from databases
- Statistical analysis and exploratory data analysis (EDA)
- Building machine learning models with XGBoost
- Response model example with scoring capabilities
- Model evaluation, decile tables, and ROC/gains charts
How to Use
- Download the app and install xlwings Lite from the Add-in button in Excel.
- Update database credentials in the app's connection section.
- Use the built-in functions:
- list_tables - Lists all tables in the connected database
- get_table_data - Retrieves table schema and sample records
- get_random_records - Pulls specified number of random records
- get_first_n_records - Retrieves first N records from a table
- get_custom_query - Executes custom SQL queries against the database
- perform_eda - Runs exploratory data analysis with distributions and correlations
- score_and_deciles - Runs XGBoost model with evaluations and decile tables
- Note: EDA and modeling functions are optimized for the included dataset. For dynamic data, check other xlwings apps.
How It Works
xlwings Lite runs as a browser-based add-in inside Excel, using Python and PyODIDE as the backend. Specific to this app:
- Database connectivity:
- Connection is established via a web layer through a custom FastAPI server
- API requests are made to the FastAPI server which connects to the specified database
- Responses are returned to Excel after processing
- Python's requests, aiohttp, or fetch APIs can be used depending on requirements
- Data processing & machine learning:
- All data processing occurs locally within the xlwings add-in
- Standard Python libraries (pandas, numpy, etc.) are available for data manipulation
- XGBoost model runs directly in the browser environment
- Visualization components generate charts and tables for analysis
Get Free Databases Quickly:
- neon.tech – Postgres database, instantly available. 500MB free
- Supabase – Postgres with auth, API, storage. 500MB free tier
- Aiven – Postgres and MySQL. 5GB free tier
- Upload data with DBeaver or rex.tigzig.com
Source Code & Resources
Source Code Location: All Python source code is embedded inside the Excel file! You can download the Excel file with embedded code from the links above.
- xlwings Lite: Official xlwings Lite website with installation instructions and examples.
- xlwings Documentation: Comprehensive documentation with Excel object reference and API documentation.
- FastAPI Server – Latest Code: The FastAPI server implementation that enables database connectivity.
- Deploy on Render: Guide for deploying the FastAPI server. For live use cases, API keys and additional security are advised.
Created by Felix Zumstein, xlwings Lite delivers a powerful and flexible solution for integrating Python with Excel - enabling native Excel support for databases, AI agents, LLMs, advanced analytics, machine learning, APIs, web services, and complete automation workflows.
About the App
xlwings Lite Quick Guide
All information about xlwings Lite is available directly in the main section of the page. Please refer to the "What This Template Shows" and "How to Use" cards for complete instructions.
Source Code and Build Guides
xlwings Lite Reference
The complete build guide information is presented in the main section of the page. Please refer to the "How It Works" and "GitHub Repos & Resources" cards on the left side for detailed implementation instructions and code resources.