<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Lay Patel</title>
    <description>The latest articles on DEV Community by Lay Patel (@laypatel13).</description>
    <link>https://dev.to/laypatel13</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4156172%2F5d2ea743-7e73-4f0c-be11-d2153db1de22.png</url>
      <title>DEV Community: Lay Patel</title>
      <link>https://dev.to/laypatel13</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/laypatel13"/>
    <language>en</language>
    <item>
      <title>SQL Doctor: An Offline Tutor That Explains PostgreSQL Errors to My DBMS Lab Classmates</title>
      <dc:creator>Lay Patel</dc:creator>
      <pubDate>Sun, 04 Oct 2026 16:12:41 +0000</pubDate>
      <link>https://dev.to/laypatel13/sql-doctor-an-offline-tutor-that-explains-postgresql-errors-to-my-dbms-lab-classmates-3bdn</link>
      <guid>https://dev.to/laypatel13/sql-doctor-an-offline-tutor-that-explains-postgresql-errors-to-my-dbms-lab-classmates-3bdn</guid>
      <description>&lt;p&gt;&lt;em&gt;This is a submission for the &lt;a href="https://dev.to/challenges/hacktoberfest-weekend-2026-10-01"&gt;Hacktoberfest Weekend Challenge: Build for a Friend&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  What I Built
&lt;/h2&gt;

&lt;p&gt;This semester I'm taking a DBMS lab where we write PostgreSQL queries every week. Writing the queries isn't the hard part. Understanding the errors is.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;column "instructor.name" must appear in the GROUP BY clause or be used in an aggregate function&lt;/code&gt; makes perfect sense once you know SQL. A few weeks into your first database course, it reads like a riddle. So I built something for my friend Jay Patel and my lab classmates.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;SQL Doctor&lt;/strong&gt; is a small web app. You paste the query that failed and the error PostgreSQL printed, and it tells you:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;What went wrong&lt;/strong&gt;, in one or two plain sentences&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Where&lt;/strong&gt;, quoting the exact part of the query that broke&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The fixed query&lt;/strong&gt;, changing only what's needed&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;A tip&lt;/strong&gt; so the same mistake doesn't happen again&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;It can explain in English, Hinglish or Gujarati, because that's how my classmates and I actually talk. You can also paste your &lt;code&gt;CREATE TABLE&lt;/code&gt; statements for more accurate answers, and there are four built-in examples of the mistakes we make most often.&lt;/p&gt;

&lt;h2&gt;
  
  
  Demo
&lt;/h2&gt;

&lt;p&gt;Try the interface at &lt;a href="https://sql-doctor.onrender.com/" rel="noopener noreferrer"&gt;sql-doctor.onrender.com&lt;/a&gt;. The hosted copy is a preview of the interface. The real answers come from Gemma running locally on your own laptop, which is the whole point, so clone the repo below to run it yourself.&lt;/p&gt;

&lt;h2&gt;
  
  
  Code
&lt;/h2&gt;


&lt;div class="ltag-github-readme-tag"&gt;
  &lt;div class="readme-overview"&gt;
    &lt;h2&gt;
      &lt;img src="https://assets.dev.to/assets/github-logo-5a155e1f9a670af7944dd5e12375bc76ed542ea80224905ecaf878b9157cdefc.svg" alt="GitHub logo"&gt;
      &lt;a href="https://github.com/laypatel13" rel="noopener noreferrer"&gt;
        laypatel13
      &lt;/a&gt; / &lt;a href="https://github.com/laypatel13/sql-doctor" rel="noopener noreferrer"&gt;
        sql-doctor
      &lt;/a&gt;
    &lt;/h2&gt;
    &lt;h3&gt;
      
    &lt;/h3&gt;
  &lt;/div&gt;
  &lt;div class="ltag-github-body"&gt;
    
&lt;div id="readme" class="md"&gt;&lt;div class="markdown-heading"&gt;
&lt;h1 class="heading-element"&gt;SQL Doctor&lt;/h1&gt;
&lt;/div&gt;
&lt;p&gt;Paste a PostgreSQL query that failed and the error it gave you. SQL Doctor explains what went wrong in plain words, points to the exact part of the query that broke, and shows the fixed query. It can explain in English, Hinglish or Gujarati.&lt;/p&gt;
&lt;p&gt;I built it for my DBMS lab classmates, who lose a lot of lab time staring at errors like &lt;code&gt;column "x" must appear in the GROUP BY clause&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;It runs entirely on your own laptop with &lt;strong&gt;Gemma 4&lt;/strong&gt;, an open-weight model, through &lt;strong&gt;Ollama&lt;/strong&gt;. Your queries never leave your machine, it works without internet, and it costs nothing to run.&lt;/p&gt;
&lt;div class="markdown-heading"&gt;
&lt;h2 class="heading-element"&gt;Run it&lt;/h2&gt;
&lt;/div&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Install &lt;a href="https://ollama.com" rel="nofollow noopener noreferrer"&gt;Ollama&lt;/a&gt; and download the model:&lt;/p&gt;
&lt;div class="highlight highlight-source-shell notranslate position-relative overflow-auto js-code-highlight"&gt;
&lt;pre&gt;ollama pull gemma4:e4b&lt;/pre&gt;

&lt;/div&gt;
&lt;p&gt;On a slower laptop, use &lt;code&gt;gemma4:e2b&lt;/code&gt; instead and change the model name in the app's sidebar.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Install the Python packages:&lt;/p&gt;
&lt;div class="highlight highlight-source-shell notranslate position-relative overflow-auto js-code-highlight"&gt;
&lt;pre&gt;python -m venv .venv
&lt;span class="pl-c1"&gt;source&lt;/span&gt; .venv/bin/activate      &lt;span class="pl-c"&gt;&lt;span class="pl-c"&gt;#&lt;/span&gt; Windows: .venv\Scripts\activate&lt;/span&gt;
pip install&lt;/pre&gt;…
&lt;/div&gt;
&lt;/li&gt;
&lt;/ol&gt;&lt;/div&gt;
  &lt;/div&gt;
  &lt;div class="gh-btn-container"&gt;&lt;a class="gh-btn" href="https://github.com/laypatel13/sql-doctor" rel="noopener noreferrer"&gt;View on GitHub&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;


&lt;h2&gt;
  
  
  How I Built It
&lt;/h2&gt;

&lt;p&gt;SQL Doctor runs entirely on the laptop:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Gemma 4 (&lt;code&gt;gemma4:e4b&lt;/code&gt;)&lt;/strong&gt; does the explaining. It's an open-weight model small enough to run on an 8 GB laptop.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Ollama&lt;/strong&gt; serves the model locally.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Streamlit&lt;/strong&gt; is the interface, about 300 lines of Python in a single file.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Most of the thinking went into the system prompt. It forces every answer into the same four sections, so answers are consistent and easy to skim. It runs at a low temperature so the fixes stay steady. And it has two rules I care about most: never invent tables or columns the student didn't mention, and say "I'm not sure" instead of guessing. A tutor that confidently gives you a wrong fix is worse than no tutor.&lt;/p&gt;

&lt;p&gt;The answer streams in as Gemma writes it. Once it's done, the sections turn into small badges: red for what broke, green for the fix. The design reuses the theme from Netra, another project of mine: neutral greys everywhere, blue only for things you can click, and color only where it carries meaning.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why Does Open Innovation Matter?
&lt;/h2&gt;

&lt;p&gt;For a student tool, open models are the whole point.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;It's free.&lt;/strong&gt; None of my classmates is going to put a credit card on an API account to debug a lab query. Gemma runs locally at zero cost per question.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;It works offline.&lt;/strong&gt; Once the model is downloaded, it doesn't need the internet at all.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Our work stays on our laptops.&lt;/strong&gt; Lab assignments never get sent to someone else's server.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;It fits the hardware.&lt;/strong&gt; If a friend's laptop is older, they can switch to &lt;code&gt;gemma4:e2b&lt;/code&gt; in the settings.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;A closed API would have meant keys, usage limits and a bill, and I couldn't hand it to a friend without handing over my key too. With Gemma and Ollama, sharing it is just &lt;code&gt;git clone&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  What Jay Said
&lt;/h2&gt;

&lt;p&gt;I showed SQL Doctor to Jay, and his reply was one word: "Crazzy! 🔥"&lt;/p&gt;

&lt;h2&gt;
  
  
  My Agent Session
&lt;/h2&gt;

&lt;p&gt;I built this with help from Claude, which helped me scaffold the Streamlit app, shape the system prompt and restyle it with my Netra theme. I then tested it on errors from my own lab work.&lt;/p&gt;

&lt;h2&gt;
  
  
  Prize Categories
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Best Use of Gemma&lt;/strong&gt;: SQL Doctor runs on Gemma 4 locally through Ollama, and Gemma does all of the explaining.&lt;/p&gt;

</description>
      <category>devchallenge</category>
      <category>weekendchallenge</category>
      <category>hf26challenge</category>
    </item>
  </channel>
</rss>
