Skip to content

This project is an LLM-powered SQL Query Generator that allows users to generate SQL queries using natural language input. Built using GPT-4, it validates and executes queries against an SQLite database. The project aims to make database querying accessible for both technical and non-technical users.

Notifications You must be signed in to change notification settings

ghaihitasha/llm-sql-query-generator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

LLM-Based SQL Query Generator

Project Overview

This project is an AI-powered SQL Query Generator that translates natural language queries into SQL statements using GPT-4. It helps users generate, validate, and execute SQL queries against a specified database schema.

User Interface

image

Features

  • Natural Language to SQL: Uses OpenAI's GPT-4 to generate SQL queries.
  • Query Validation: Ensures generated queries are syntactically correct.
  • Database Execution: Runs SQL queries against an SQLite database.
  • Custom Schema Support: GPT generates SQL based on your database schema.
  • User-Friendly UI: Built with Streamlit for ease of use.
  • Secure API Key Management: Users can input their OpenAI API Key manually or load it from a .env file.

Tech Stack

  • Backend: Python, OpenAI API, SQLite
  • Frontend: Streamlit
  • Libraries: SQL Parsing, python-dotenv

🚀 Installation & Setup

1️. Clone the Repository

git clone https://github.com/ghaihitasha/llm-sql-query-generator.git
cd llm-sql-query-generator

2. Install Dependencies

pip install -r requirements.txt

3. Set Up the .env File

Create a .env file in the root directory and add your OpenAI API Key:

OPENAI_API_KEY=your_openai_api_key_here

4. Run the Streamlit App

streamlit run src/app.py

Usage

  1. Enter your OpenAI API Key in the Project Settings section or let it load from .env.
  2. Provide the database path to your SQLite file.
  3. Enter a natural language query (e.g., "Show all employees who joined after 2020").
  4. Click Generate SQL to get the SQL query.
  5. Validate & Execute the query to see the results.

Contributing

Pull requests are welcome! If you’d like to contribute, please open an issue first to discuss your changes.

About

This project is an LLM-powered SQL Query Generator that allows users to generate SQL queries using natural language input. Built using GPT-4, it validates and executes queries against an SQLite database. The project aims to make database querying accessible for both technical and non-technical users.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published