Skip to content

DB Unchained: Unlock DB Queries with AI-powered, dynamic queries generated via LangChain and OpenAI. πŸš€

License

Notifications You must be signed in to change notification settings

zlatanned/db-unchained

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

14 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

DB-Unchained πŸ§ πŸ”—

Turn plain English into database queries using AI with Auto Language Detection.

Example:

Prompt: Fetch all names and emails of users aged 25 or below from users table

Output:

SELECT name, email FROM users WHERE age <= 25;

πŸš€ Why DB-Unchained?

Tired of writing raw SQL or remembering Mongo filters? Just describe what you want β€” DB-Unchained translates your intent into a query.


πŸ› οΈ Features

  • βœ… Converts English prompts to queries using LLM
  • πŸ” Auto Language Detection Mode (Supports all existing Query Languages)
  • 🌐 Support for multiple query languages in Manual Language Selection Mode (SQL or MongoDB)
  • πŸ” Pluggable LLMs (OpenAI, Groq etc.)
  • πŸ”§ Configurable via environment variables
  • πŸ“¦ Dockerized for easy deployment
  • ✨ Clean and modular structure, built for scaling

πŸ§ͺ Example Prompts to Try

Prompt Output Example
List all customers who joined in the last 30 days SELECT * FROM customers WHERE created_at >= NOW() - INTERVAL 30 DAY;
Fetch products that are out of stock SELECT * FROM products WHERE stock = 0;
Get users from New York aged between 20 and 30 SELECT * FROM users WHERE city = 'New York' AND age BETWEEN 20 AND 30;
Show total revenue for each product category SELECT category, SUM(revenue) FROM products GROUP BY category;
Find all employees who haven't submitted their timesheet SELECT * FROM employees WHERE id NOT IN (SELECT employee_id FROM timesheets);

βš™οΈ Configuration

All config is managed via environment variables. Example .env:

LLM_PROVIDER=groq
ENABLE_AUTO_DETECT=true
GROQ_API_KEY=your-groq-api-key-here
GROQ_MODEL=model-you-want-to-use
  • βœ… Node.js v22+ supported natively with .env file alternatives
  • πŸ” Never commit your .env with secrets

πŸ” How to Get Groq API Key


▢️ Run Locally

# Install deps
npm install --omit=dev

# Run
npm start
  • (if ENABLE_AUTO_DETECT = true) You’ll be prompted to enter your preferred query language followed by a plain text in your natural language. The app will return a raw DB query (acc to your selected query language in first prompt) using the selected LLM.

  • (if ENABLE_AUTO_DETECT = false) You’ll be prompted to enter a plain text in your natural language. The app will return a raw DB query with automatic language selection based on your prompt and general popularity.


🐳 Docker

# Build
docker build -t db-unchained .

# Run with env
docker run -it --env-file .env db-unchained
  • Make sure .env contains your API key and configs.

🀝 Contributing

PRs welcome. Just don’t break the modularity. Keep things clean, minimal, and extendable.

πŸ§‘β€πŸ’» Author

Made with ❀️ by zlatanned.

About

DB Unchained: Unlock DB Queries with AI-powered, dynamic queries generated via LangChain and OpenAI. πŸš€

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published