QueryNL - Natural Language Database Queries from the Terminal
Query your databases using plain English. No SQL required.
Features
- Natural Language Queries: Ask questions in plain English, get SQL results
- AI-Powered: Uses OpenAI GPT-4 or Anthropic Claude for intelligent query generation
- Multi-Database: PostgreSQL, MySQL, SQLite, MongoDB support
- Schema Design: Design database schemas through conversation
- Test Data Generation: Automatically populate tables with realistic data
- Interactive REPL: Tab completion, history, and context-aware queries
- Secure: Credentials stored in OS keychain, SSL/TLS by default
- Safe: Preview SQL before execution, confirmations for destructive operations
Installation
From PyPI (Coming Soon)
pip install querynl-cli
From Source
pip install git+https://github.com/yourusername/QueryNL.git
Prerequisites
- Python 3.10 or higher
- OpenAI or Anthropic API key (for AI features)
Quick Start
1. Configure LLM Provider
# Using OpenAI
querynl config llm --provider openai --test
# Or using Anthropic Claude
querynl config llm --provider anthropic --test
2. Add a Database Connection
querynl connect add mydb
# Follow the interactive prompts
3. Start Querying
querynl repl
querynl (mydb)> show me all users created this month
querynl (mydb)> count orders by status
querynl (mydb)> find top 10 products by revenue
Usage Examples
Natural Language Queries
# In REPL mode
querynl repl
querynl> show me all active users
querynl> count orders grouped by status
querynl> find products with price > 100
querynl> update user email where id = 5
Schema Design
Create database schemas through natural language conversation:
querynl> \schema design
Schema Designer> I need a blog with users, posts, and comments
Schema Designer> posts should have titles and content
Schema Designer> users can comment on posts
Schema Designer> finalize
# Execute the generated schema
querynl> \schema execute
Test Data Generation
Populate your tables with realistic test data:
querynl> add sample data
querynl> add 100 users and 500 posts
querynl> add e-commerce product data
Command-Line Mode
# Execute a single query
querynl query exec "count all users"
# Output as JSON
querynl query exec --format json "all active users"
# Save to file
querynl query exec --output data.csv --format csv "all orders"
# Preview SQL without executing
querynl query exec --explain "delete old records"
Key Features
🤖 AI-Powered Query Generation
- Understands context and database schema
- Generates optimized SQL queries
- Supports complex joins, aggregations, and subqueries
- Confidence scoring for query accuracy
🔒 Security First
- Credentials stored in OS keychain (macOS, Windows, Linux)
- SSL/TLS enabled by default
- Preview SQL before execution
- Confirmation prompts for destructive operations (DELETE, DROP, etc.)
- No credentials in config files or logs
🎨 Beautiful Terminal UI
- Syntax-highlighted SQL
- Formatted table output
- Progress bars for long operations
- Tab completion for commands and tables
- Persistent command history
🌐 Multi-Database Support
- PostgreSQL - Full support
- MySQL - Full support
- SQLite - Full support
- MongoDB - Basic support
📊 Schema Design & Test Data
- Design schemas through natural language
- Generate DDL for any database
- View ER diagrams in terminal
- Populate tables with realistic test data
- Respects foreign keys and constraints
Configuration
Config File Locations
- macOS:
~/Library/Application Support/querynl/config.yaml - Linux:
~/.config/querynl/config.yaml - Windows:
%APPDATA%\querynl\config.yaml
Environment Variables
| Variable | Description |
|---|---|
QUERYNL_CONNECTION_STRING |
Database connection string |
QUERYNL_KEYRING_PASSWORD |
Master password for headless servers |
QUERYNL_CONFIG |
Custom config file path |
QUERYNL_NO_COLOR |
Disable color output |
REPL Commands
| Command | Description |
|---|---|
\help |
Show available commands |
\tables |
List all tables in database |
\schema |
Display database schema |
\schema design |
Start schema design mode |
\schema execute |
Execute generated DDL |
\history |
Show query history |
\clear |
Clear screen |
exit or \quit |
Exit REPL |
Examples
E-commerce Analytics
querynl> show top 10 customers by total order value
querynl> count orders by status for last month
querynl> find products with low inventory
User Management
querynl> show users who signed up this week
querynl> count active users by region
querynl> find users with no recent activity
Data Cleanup
querynl> delete records older than 90 days from logs
querynl> update email domain from old.com to new.com
querynl> remove duplicate entries from customers
Troubleshooting
Connection Issues
# Test your connection
querynl connect test mydb
# List all connections
querynl connect list
# Remove and re-add connection
querynl connect remove mydb
querynl connect add mydb
Keychain Access (macOS)
If you get "Permission denied to access keychain":
- Open Keychain Access app
- Search for "querynl"
- Right-click → Get Info → Access Control
- Add Terminal/iTerm to allowed applications
Headless Servers (Linux)
# Use encrypted file keyring
export QUERYNL_KEYRING_PASSWORD="your-master-password"
querynl connect add mydb
Documentation
Support
- 🐛 Report Issues
- 💬 Discussions
- 📧 Email: support@querynl.com
License
MIT License - see LICENSE file for details
Acknowledgments
Built with:
- Click - CLI framework
- Rich - Terminal formatting
- LangChain - LLM orchestration
- SQLAlchemy - Database toolkit
- Faker - Test data generation
Made with ❤️ for developers who prefer English over SQL
Metadata
Release files for querynl-cli 0.2.7
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| querynl_cli-0.2.7.tar.gz | 337.1 kB | Without provenance | Details for querynl_cli-0.2.7.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| querynl_cli-0.2.7-py3-none-any.whl | Python 3 | none | any | Details for querynl_cli-0.2.7-py3-none-any.whl |
Total release size: 470.7 kB
Release files / querynl_cli-0.2.7.tar.gz
| Download URL | querynl_cli-0.2.7.tar.gz |
|---|---|
| Size | 337.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
96910405cade4bf6593ad97fd2720ec1c5f1408168561ab2145ede46d89023dd
|
|
BLAKE2b-256 checksum How to use checksums |
1dad8c198149e77ceec9da875ea14765942532aa4f2161fccffb02430ffa391f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.6
|
Release files / querynl_cli-0.2.7-py3-none-any.whl
| Download URL | querynl_cli-0.2.7-py3-none-any.whl |
|---|---|
| Size | 133.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
11f0fc1a1cc7d50baae3076a5eea910f1e358e8528c5ff401f8b9ac1c1215bfa
|
|
BLAKE2b-256 checksum How to use checksums |
ff2b490f24617c21a308e133e32acf49642a0a80ea7c0c89b77b0589177e136d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.6
|
Security for querynl-cli 0.2.7
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.