← Portfolio
Software Dev

Prompt to SQL

Type Web App
Framework FastAPI
Language Python
Deploy Docker
Repository View on GitHub ↗

Overview

Prompt-to-SQL is a secure FastAPI web application that converts natural-language prompts into SQL queries. Users can type a question in plain English and receive a valid SQL statement — optionally scoped to a real table schema inferred from an uploaded CSV or Excel file.

The app supports multiple SQL dialects, a flexible LLM provider chain (OpenAI → Ollama → deterministic template fallback), and enforces read-only guardrails that block any destructive SQL intent at the API level.

Features

  • Plain-text prompt → SQL with optional CSV/Excel schema inference
  • SQL dialect selector: ANSI, PostgreSQL, MySQL, SQLite, SQL Server
  • Read-only guardrails blocking INSERT, UPDATE, DELETE, DROP, etc.
  • LLM provider priority: OpenAI → Ollama → template fallback
  • Optional API key protection (X-API-Key header) and per-IP rate limiting
  • Uploaded files processed in-memory only — never written to disk

Tech Stack

  • Python + FastAPI — backend API and SQL generation logic
  • OpenAI / Ollama — LLM providers for natural language understanding
  • Docker — containerized deployment
  • HTML/JS — lightweight frontend UI