This repository contains a small SQL agent that uses IBM Watsonx (WatsonX) and LangChain to run SQL queries against a MySQL database.
Security first: Do NOT commit secrets or credentials. Fill in a local .env file (copy from .env.example) and add it to .gitignore.
Quick start
- Create and activate a virtual environment
python -m venv venv
# Windows
venv\Scripts\activate
# macOS / Linux
source venv/bin/activate- Install dependencies
pip install -r requirements.txt- Copy
.env.exampleto.envand update values with your own credentials
cp .env.example .env
# Edit .env and fill in WATSONX_URL, WATSONX_APIKEY, and database settings- Run the agent
python sqlagent.py --prompt "SELECT * FROM Album LIMIT 5;"
# Or override DB URI directly:
python sqlagent.py --db-uri "mysql+mysqlconnector://user:pass@host:3306/Chinook" --prompt "SELECT * FROM Album LIMIT 5;"