This project implements a natural-language to SQL agent that allows users to query and modify multiple mock databases using plain English. It supports CRUD operations with a human-in-the-loop verification system to ensure safe database modifications.
The project is built with:
- Python + FastAPI for backend REST API
- SQLite for multiple mock databases (HR, Healthcare, E-commerce, Finance, Education)
- πΉ Interact with 5 mock databases (
hr.db,healthcare.db,ecommerce.db,finance.db,education.db) - πΉ Natural language CRUD support (Read/Write/Update/Delete)
- πΉ Human-in-the-loop approval for Create/Update/Delete before commit
- πΉ Pending queue manager to track and approve/reject modifications
- πΉ FastAPI REST endpoints with interactive Swagger UI
git clone https://github.com/your-username/mini-sql-agent.git
cd mini-sql-agentpython -m venv venv
source venv/bin/activate # on Linux/Mac
venv\Scripts\activate # on Windowspip install -r requirements.txt
after completed,
pip install langchain_google_genaiCreate a .env file in the project root and add your Gemini API key:
GEMINI_API_KEY=your_api_key_here
with Uvicorn:
uvicorn main:app --reload --port 8000Once running, access:
- API Docs: [http://localhost:8000/docs] (http://localhost:8000/docs) and initialize database and test your nl-queries
- Example endpoint:
/query?text=Show all employees in HR&db=hr - Make sure that the backend url set in app.js is same as localhost port, else change it accordingly.
This is a classic agentic made with (langchain-LangGraph) but yet slow with other LLMs. Do try LangSmith Integration, added in the requirements. Add your LangSmith api directly via env file.
=======