DEV Community

TSAI PEI-LIN
TSAI PEI-LIN

Posted on

Why I Built USPL: Helping GPT Understand Multi-Table SQL

Intro:

I didn’t set out to build a tool.

I just wanted GPT to stop hallucinating when I asked it to join two tables.

That led me to spend late nights thinking about schemas, prompts, and how language models "see" structured data.

👨‍💻 What is USPL?

USPL (Unified Schema Prompt Layer) is a lightweight Python framework that turns natural language into SQL — specifically for multi-table relational databases — using GPT-3.5.

It helps GPT generate JOINs, understand foreign keys, and compose queries over normalized schemas.

It’s open source, documented in English & Traditional Chinese, and licensed under MIT.
👉 GitHub Repo

💡 Why I Built It

Language models are powerful, but they struggle with:

Schema complexity

Relational reasoning

JOIN logic across multiple tables

Even fine-tuned LLMs need better input.

I didn’t want to fine-tune a model.
I wanted to change the prompt — and prove that was enough.

So I designed a prompt format that compresses schema metadata into a clean, LLM-friendly JSON.
No sample data, just pure structure and meaning.

This became the core of USPL.

🧪 How It Works

User describes their schema (as a JSON unified prompt)

User asks a natural language question

GPT generates SQL

Python executes it

GPT summarizes the result in plain language

That’s it.
All without training, plugins, or special tooling.

📘 The Tech Stack

Python

OpenAI API (GPT-3.5-turbo)

SQLite (execution layer)

Dotenv / CLI interface

MIT License

🧠 What I Learned

Prompt design is data engineering.

GPT performs best when we remove ambiguity, not when we add more power.

Documentation matters.

Building in public makes me sharper.

🌸 Closing Thoughts

I’m TSAI PEI LIN, a fullstack engineer from Taiwan.
This project was made during my off-hours, driven by frustration, curiosity, and a love for structure.

If you work on AI + data tools, I’d love to connect.
Fork the repo, try it, break it — I’m happy either way.

USPL is not the end, it’s just the first layer.

GPT #SQL #OpenSource #LLM #PromptEngineering #Python #SideProject #Devtools #Taiwan

Top comments (1)

Collapse
 
donkey_d_8fe161b59fbb5225 profile image
TSAI PEI-LIN

📢 Update: I just shared this post on Twitter as well!

If you'd like to help signal-boost or leave feedback there, here's the tweet:

👉 x.com/TSAI_PEI_LIN/status/19067923...

Thanks to everyone reading this! 🙌

This project was a weekend build driven by frustration and curiosity.
If you're also exploring GPT for structured data tasks — feel free to fork, remix, or reach out!

Let’s keep making LLMs more useful in the real world ✨