Jignesh Patel
1 min read

Query using natural language

Since I am never organized with my ad-hoc SQL queries, I’ve always wanted to query my OpticoBot DB using natural language rather than typing in SQL every time, especially when I don’t remember the table, column names and mistype them the first time.

Coding a TUI

Just for giggles, I thought why not a TUI. Enter Claude Code by Anthropic and a few prompts later an initial version was born in less than an hr!

Example session

Example Session

It’s frankly mind blowing what Claude can do! It designed the TUI, hooked up to Cloudflare using wrangler and using Anthropic APIs to convert natural language to SQL the first version was running almost immediately.

System architecture

System Architecture

A few iterations later, I had history and help. Now I can lazily give it terse prompts and it writes the SQL, executes it and shows me the results. Remembers context of previous queries and also has re-tries.

Would I write the same SQL as the LLM. Probably not, but it works!