How I built natural language querying for a SQL database

A writeup of the early learnings from building my first GPT-based application

Yakko Majuri
7 min readJun 10, 2023

For what felt like the longest time, I pretty much ignored the developments happening in the generative AI/LLM (large language model) space.

I knew there was a lot of cool stuff happening, I just didn’t get around to trying it out very much.

Then I had the chance to look over how a friend was using ChatGPT on his day-to-day and decided it was time to build out a little project.

I’ve spent the last few weeks building out an open source tool for monitoring and managing ClickHouse clusters called HouseWatch, and wondered about how I incorporate GPT into it to build a new feature.

What I landed on was natural language querying.

HouseWatch has a lot of features aimed at giving you an overview of how your ClickHouse node/cluster is doing, but it also has a built-in query editor so you can dig deeper beyond the information already provided. Unlike a lot of other databases, ClickHouse gives you a ton of metadata about the system in its system tables, so often times when debugging issues, I’m actually writing ClickHouse SQL to extract the data I need from these tables.

--

--

Yakko Majuri

Programmer, writer, traveler, hitchhiker, climber, photographer. i.e. lost. (P.S. amateur at most of the above) // memoirsandrambles.substack.com