๐ฏ 88% execution accuracy on Spider benchmark with zero API costs and 100% data privacy
๐ Bilingual support - Works perfectly with English and Chinese queries
English | ไธญๆๆๆกฃ
- ๐ธ Ongoing Costs: Continuous API fees that scale with usage
- ๐ Privacy Risk: Your sensitive data leaves your infrastructure
- ๐ Network Dependency: Requires internet, adds latency
- ๐ซ Compliance Issues: Many industries can't send data to cloud
- โ Zero Cost: No API fees, ever
- ๐ 100% Private: Data never leaves your machine
- โก Fast: 3.7-5.4 seconds average response time
- ๐ Proven: 88% execution accuracy on Spider benchmark (NEW: qwen3-coder:30b)
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ ๐ Your Local Environment โ
โ โ
โ โโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโ โ
โ โ User โโโโโโถโ LocalSQLAgent โโโโโโถโ Ollama + LLM โ โ
โ โ Query โ โ (Intelligent โ โ qwen3-coder:30b โ โ
โ โโโโโโโโโโโโโโ โ Agent) โ โโโโโโโโโโโโโโโโโโโ โ
โ โโโโโโโโโโฌโโโโโโโโโโ โ
โ โผ โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ Your Databases โ โ
โ โ PostgreSQLโMySQLโMongoDBโ... โ โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ
โ ๐ฐ $0 Cost ๐ 100% Private โก 3.7s Avg ๐ 88% EA โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
# macOS/Linux
curl -fsSL https://ollama.com/install.sh | sh
# Pull the best model (18GB, requires 25GB RAM)
ollama pull qwen3-coder:30b
# Or for limited resources (4.7GB, requires 6GB RAM)
ollama pull qwen2.5-coder:7bgit clone https://github.com/tokligence/LocalSQLAgent.git
cd LocalSQLAgent
pip install -e .from localsql import IntelligentSQLAgent
# Connect to your database
agent = IntelligentSQLAgent("postgresql://localhost/mydb")
# Ask questions in natural language
result = agent.query("Show me top 10 customers by revenue last month")
print(result)- 88% execution accuracy on Spider benchmark* - Highest accuracy achieved!
- 3.69s average response time - 32% faster than qwen2.5-coder
- 18GB disk space (MoE: 30B total, 3.3B active)
- ~25GB RAM required
- Key advantage: Mixture-of-Experts architecture delivers superior performance
- 86% execution accuracy on Spider benchmark*
- 5.4s average response time
- 4.7GB disk space
- ~6GB RAM required
*Tested on MacBook Pro (M-series, 48GB RAM) with Spider dev dataset (50 samples)
| Model | EA (%) | Speed | Size | Verdict |
|---|---|---|---|---|
| qwen3-coder:30b ๐ | 88% | 3.69s | 18GB | โ Best overall |
| qwen2.5-coder:7b | 86% | 5.41s | 4.7GB | โ Best for limited RAM |
| codestral:22b | 82% | 30.6s | 12GB | |
| qwen2.5:14b | 82% | 10.0s | 9.0GB | โ General model |
| deepseek-coder:6.7b | 72% | 6.64s | 3.8GB | |
| deepseek-coder-v2:16b | 68% | 4.0s | 8.9GB |
Key Finding: MoE architecture (qwen3-coder:30b) achieves best results - 88% EA with only 3.3B active params!
View detailed model analysis โ
- Automatically learns from SQL execution errors
- Self-corrects common mistakes (ambiguous columns, missing GROUP BY, etc.)
- Achieves up to 88% accuracy through error recovery (qwen3-coder:30b)
# English
result = agent.query("Show me sales trends")
# ไธญๆๅๆ ทๅฎ็พๆฏๆ
result = agent.query("ๆพ็คบไธไธชๆ้ๅฎๅ10็ไบงๅ")- PostgreSQL, MySQL, SQLite
- MongoDB (via SQL interface)
- ClickHouse, DuckDB
- Any SQL-compatible database
- REST API with FastAPI
- Docker support
- Concurrent request handling (10+ QPS)
- Comprehensive test suite
- Execution Accuracy (EA): 88% ๐
- Average Latency: 3.69s โก
- Average Attempts: 2.5
- Success Rate: 100% (with retries)
- Execution Accuracy (EA): 86%
- Average Latency: 5.41s
- Average Attempts: 2.5
- Success Rate: 100% (with retries)
| Attempts | EA (%) | Latency | Finding |
|---|---|---|---|
| 1 | 84% | 2.4s | Fast but may fail |
| 5 | 85% | 4.0s | +1% EA improvement |
| 7 | 85% | 4.8s | No further gain |
Recommendation: Use 1-3 attempts for best speed/accuracy balance
# Start the API server
python api_server.py
# Query via HTTP
curl -X POST http://localhost:8000/query \
-H "Content-Type: application/json" \
-d '{"query": "Show me all users who joined this month"}'docker build -t localsqlagent .
docker run -p 8000:8000 localsqlagentagent = IntelligentSQLAgent(
db_url="postgresql://localhost/mydb",
model_name="qwen3-coder:30b", # Use best model for highest accuracy
max_attempts=3,
temperature=0.1
)| Solution | Cost Model | Data Privacy | Setup Time |
|---|---|---|---|
| LocalSQLAgent | Free Forever | โ 100% Local | 5 minutes |
| Cloud APIs | Usage-based billing | 30 minutes | |
| Self-hosted GPU | Infrastructure costs | โ Local | Days-Weeks |
We welcome contributions! See CONTRIBUTING.md for guidelines.
Apache 2.0 - Free for commercial use
- Powered by Ollama
- Spider dataset from Yale University
- Built with love by Tokligence
Ready to eliminate API costs? Star โญ this repo and get started in 5 minutes!