███╗ ██╗ █████╗ ██████╗
████╗ ██║██╔══██╗██╔═══██╗
██╔██╗ ██║███████║██║ ██║
██║╚██╗██║██╔══██║██║▄▄ ██║
██║ ╚████║██║ ██║╚██████╔╝
╚═╝ ╚═══╝╚═╝ ╚═╝ ╚══▀▀═╝
AI Natural Language → SQL Engine
NAQ is an open-source terminal AI assistant that lets you query your SQL databases using plain English.
No SQL knowledge required. Just describe what you want, and NAQ generates and runs the query for you.
NAQ > show me the top 10 customers by total revenue
┌──────────────┬──────────────┐
│ customer │ revenue │
├──────────────┼──────────────┤
│ Alice Corp │ 128,400.00 │
│ Beta Systems │ 98,200.00 │
│ … │ … │
└──────────────┴──────────────┘
10 rows returned.
| Feature | Description |
|---|---|
| 🗣️ Natural Language | Ask questions in plain English |
| 🤖 Multi-LLM | Supports OpenAI (GPT-4o, GPT-4o-mini) and Groq (Llama 3, Mixtral) |
| 🗄️ Multi-Database | MySQL |
| 🔍 Schema Awareness | Auto-loads your database schema for accurate SQL generation |
| 🛡️ Safety Layer | Blocks DROP, TRUNCATE, ALTER; confirms DELETE, UPDATE |
| 📊 Rich Tables | Beautiful terminal output with Rich |
git clone https://github.com/harrison007123/NAQ.git
cd naq
pip install -e .naqOn first run, the setup wizard will guide you through:
- LLM provider — Choose OpenAI or Groq
- API key — Your OpenAI or Groq key
- Database — MySQL or PostgreSQL connection details
NAQ > show top 10 customers by revenue
NAQ > how many orders were placed last month?
NAQ > list products with stock below 20
NAQ > which users signed up in the last 7 days?
NAQ > what is the average order value by country?
| Command | Description |
|---|---|
help |
Show all available commands |
schema |
Display full database schema |
schema refresh |
Force reload schema from database |
config |
Re-run the setup wizard |
exit / quit |
Exit NAQ |
naq --version # Print version
naq --setup # Force re-run setup wizard
naq --help # Show helpnaq/
├── naq/
│ ├── __init__.py # Package metadata & version
│ ├── cli.py # Interactive REPL & Typer entry point
│ ├── banner.py # ASCII banner & startup display
│ ├── config.py # Setup wizard & config management
│ ├── db.py # SQLAlchemy connection manager
│ ├── schema_loader.py # Auto-detect tables, columns, FKs
│ ├── safety.py # SQL safety layer
│ ├── ai_engine.py # LLM integration (OpenAI / Groq)
│ ├── executor.py # SQL execution → pandas DataFrame
│ └── utils.py # History, Rich table renderer
├── pyproject.toml # PEP 517 build config
├── requirements.txt
├── LICENSE
├── README.md
| Library | Purpose |
|---|---|
typer |
CLI framework |
rich |
Terminal UI & tables |
sqlalchemy |
Database connectivity |
pandas |
Result formatting |
prompt_toolkit |
Interactive REPL |
requests |
LLM API calls |
Supported LLM models:
- OpenAI:
gpt-4o,gpt-4o-mini,gpt-4-turbo,gpt-3.5-turbo - Groq:
llama3-70b-8192,llama3-8b-8192,mixtral-8x7b-32768
NAQ has a built-in SQL safety layer:
DROP,TRUNCATE,ALTER→ permanently blockedDELETE,UPDATE,INSERT→ requires explicit confirmationSELECT→ always allowed
Contributions are welcome! Please open an issue or submit a pull request on GitHub.
git clone https://github.com/harrison007123/NAQ.git
cd naq
python -m venv .venv
source .venv/bin/activate # Windows: .venv\Scripts\activate
pip install -e ".[dev]"MIT © NAQ Contributors — see LICENSE.