DEV Community

Hassan Ahmed
Hassan Ahmed

Posted on

Natural Language to SQL: University Student Data Query App with LLMs

I recently built a small project that lets you query a university student database using natural language instead of SQL.

What it Does

You can type queries like:
Show all students in Data Science

The app uses a large language model (LLaMA 3 via Groq) to convert your plain-English query into SQL, runs it on a local SQLite database, and shows the results in a simple web UI built with Streamlit.

Why Build This?

I wanted to explore how language models can make databases more accessible for people without SQL knowledge. This also gave me hands-on experience integrating LLMs with backend databases and building a full-stack app.

Tech Stack

  • Python
  • Streamlit for the UI
  • LangChain for prompt management
  • Groq API for fast LLaMA 3 inference
  • SQLite for the database

How It Works

  1. User enters a natural language query in the UI
  2. LangChain structures a prompt for the LLM
  3. Groq’s LLaMA 3 model generates SQL from the query
  4. SQLite executes the SQL query
  5. Results display in the web interface

Check It Out

You can find the full source code here:
https://github.com/Hassan123j/Natural-Language-to-SQL-University-Student-Data-Query-App

Feedback and contributions are welcome!

Top comments (0)