Skip to content

Latest commit

 

History

4 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation


🤖 Talk to Your Database (Text-to-SQL)

An AI-powered application that allows users to query a SQLite database using natural language. Built with Streamlit, LangChain, and Groq (Llama 3.1).

🚀 Features

  • Natural Language Processing: Converts English questions into valid SQL queries.
  • Live Execution: Runs generated queries against a local SQLite database and displays results.
  • Streamlit UI: A clean, interactive web interface for user input and data visualization.
  • Dockerized: Easy to deploy and run in a containerized environment.

🛠️ Project Structure

├── main.py              # Streamlit application logic
├── database.py          # Script to initialize and seed the SQLite DB
├── requirements.txt     # Python dependencies
├── .env                 # Environment variables (API Keys)
├── .gitignore           # Files excluded from Git
├── Dockerfile           # Docker configuration
└── student.db           # SQLite database (generated locally)


⚙️ Setup Instructions

1. Clone the Repository

git clone [https://github.com/aniketbhoy/Text-to-SQL.git](https://github.com/aniketbhoy/Text-to-SQL.git)
cd Text-to-SQL

2. Configure Environment Variables

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

GROQ_API_KEY=your_lp_api_key_here

3. Local Installation (Python)

It is recommended to use a virtual environment:

# Create virtual environment
python -m venv myenv

# Activate it (Mac/Linux)
source myenv/bin/activate

# Install dependencies
pip install -r requirements.txt

# Initialize the database
python database.py

# Run the app
streamlit run main.py

🐳 Running with Docker

This project is fully containerized. You can build and run it without needing to install Python locally.

Build the image:

docker build -t text-to-sql:latest .

Run the container:

docker run -p 8501:8501 --env-file .env text-to-sql

Then visit http://localhost:8501 in your browser.


📊 Database Schema

The app queries a STUDENT table with the following structure:

Column Type Description
NAME VARCHAR Name of the student
COURSE VARCHAR Subject of study
SECTION VARCHAR Class section (A, B, etc)
MARKS INT Exam score

📝 Example Queries to Try

  • "How many students are there?"
  • "Show me all students in the Data Science course."
  • "Who got the highest marks in Section A?"
  • "List the names of students in DEVOPS."

🛡️ License

Distributed under the MIT License. See LICENSE for more information.


---

About

An AI-powered application that allows users to query a SQLite database using natural language. Built with Streamlit, LangChain, and Groq (Llama 3.1).

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages