← Back to public projects
01AI + DATA

Ask Your Database

Natural Language → PostgreSQL Assistant

A modular Python application that turns plain-English questions into safe SQL, validates and repairs generated queries, executes them against a read-only PostgreSQL database, and summarizes results back in natural language.

PythonPostgreSQLOllamaLlama 3Prompt Engineering

The problem

What needed solving

Let non-SQL users explore relational data without giving a language model unrestricted access to a database.

The approach

How I designed it

I separated generation, validation, execution and summarization into independent steps. The model proposes SQL, the application validates it, execution happens through read-only access, failures can be repaired, and the result is summarized for the user.

Interactive architecture

Click through the system.

STEP 01Question

The user asks a question in plain English.

Highlights

What matters in the implementation.

01Schema-aware prompting
02Read-only execution
03Automatic query repair
04SQL validation guardrail
05Plain-English result summaries