Open source · Provider agnostic

Ask your database anything

A mountable Rails engine that turns natural language into SQL. Powered by any LLM. Think Blazer meets ChatGPT.

Get Started View on GitHub
$ gem "query_lens" click to copy
querylens — localhost:3000/query_lens
Recents
Revenue by plan
User signups
Churn analysis
Saved Queries
Revenue Analytics
User Metrics
You
What's the total revenue by plan this quarter?
QueryLens
Here's the revenue breakdown by plan for Q1 2026:
SELECT plans.name, SUM(invoices.amount) AS total
FROM invoices
JOIN plans ON plans.id = invoices.plan_id
WHERE invoices.created_at >= '2026-01-01'
GROUP BY plans.name ORDER BY total DESC
Results 3 rows · 12ms
PlanTotal Revenue
Enterprise$284,500.00
Professional$127,350.00
Starter$43,200.00
Works with any LLM provider via RubyLLM
OpenAI Anthropic Gemini DeepSeek Mistral Ollama

Everything you need to query with confidence

Natural language SQL generation with the security, organization, and developer experience your team expects.

💬

Natural Language to SQL

Ask questions in plain English. QueryLens generates, explains, and executes the SQL — with follow-up conversation support for iterative refinement.

📁

Saved Queries & Projects

Save known-good queries, organize them into projects, and share across your admin team. Like Blazer's saved queries, but with AI generation built in.

🧠

Smart Schema Handling

Two-stage AI generation for large databases. Sends only relevant table schemas to the LLM, keeping requests fast and cost-effective even at scale.

💬

Conversation History

Auto-saved conversations persist across page refreshes. Browse recent chats in a Claude-style sidebar, pick up where you left off.

🔌

Any LLM Provider

Powered by RubyLLM. Swap between OpenAI, Claude, Gemini, DeepSeek, Ollama, or any of 10+ supported providers with a single config line.

Zero Dependencies

Self-contained CSS and vanilla JavaScript. No webpack, no node_modules, no build step. Mount the engine and go.

Up and running in two minutes

Three commands to install. One config file to customize. Then visit /query_lens and start asking questions.

01

Install the gem

Add QueryLens to your Gemfile, run the installer, and migrate. The installer creates your config, routes, and database tables.

gem "query_lens"

$ bundle install
$ rails generate query_lens:install
$ rails db:migrate
02

Configure your provider

Point QueryLens at any LLM. Set your API key, pick a model, configure auth, and optionally exclude sensitive tables.

RubyLLM.configure do |config|
  config.anthropic_api_key = ENV["ANTHROPIC_API_KEY"]
end

QueryLens.configure do |config|
  config.model = "claude-sonnet-4-5-20250929"
  config.excluded_tables = %w[api_keys secrets]
end
03

Start querying

Visit /query_lens in your browser. Ask anything about your data in natural language. Save queries you'll use again.

"How many users signed up this month?"
"What's the total revenue by plan?"
"Show me the top 10 accounts by volume"
"Break that down by month"

Defense in depth, not an afterthought

Multiple overlapping layers ensure that even if one check fails, your data stays safe. Production-grade from day one.

Read-only transactions

All queries execute inside SET TRANSACTION READ ONLY on PostgreSQL. Writes are impossible at the database level.

SQL parsing & blocklist

Only SELECT and WITH (CTE) statements are allowed. INSERT, UPDATE, DELETE, DROP, and dangerous functions are blocked.

Table enforcement

Excluded tables are hidden from the AI and blocked at execution. Even manually typed queries can't access restricted tables.

Configurable auth & audit

Lambda-based authentication, per-query timeouts, row limits, and full audit logging of every execution and blocked attempt.

Stop writing SQL.
Start asking questions.

QueryLens is ready to mount in your Rails app today. Your database already has the answers.

Get Started View on GitHub