Skip to content

Transform natural language into SQL queries using Azure OpenAI. Visualize database results with interactive charts and explore data effortlessly.

Notifications You must be signed in to change notification settings

lohitkolluri/NLP2SQL

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

59 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Banner

Made with Google Gemini Built with Streamlit Database

🎯 Transform natural language into powerful SQL queries with ease!

Magnifying Glass Turn your words into SQL magic Chart Visualize your data dynamically Tabs Multi-database support

✨ Features

🎯 Core Features
  • Natural Language to SQL 🗣️ → 📝
    • Convert text queries into SQL commands using Google's Gemini Pro model
    • Intelligent query interpretation with detailed decision logs
    • Step-by-step reasoning for query generation
  • Multi-Database Support 🗄️
    • SQLite compatibility with file upload
    • PostgreSQL integration with secure connection
    • Dynamic schema exploration
  • Interactive Data Explorer 🔍
    • Real-time data filtering and exploration
    • Comprehensive query results with summary statistics
    • Advanced table views with sorting and filtering
📊 Visualization & Analytics
  • Dynamic Visualizations 📈
    • Multiple chart types (Bar, Line, Scatter, Area, Histogram)
    • Interactive chart configuration
    • AI-powered visualization recommendations
  • Summary Statistics 📋
    • Detailed numeric analysis
    • Categorical data insights
    • Distribution analysis
    • Statistical measures (mean, median, mode, skewness, kurtosis)
🛡️ Security & Management
  • Safe SQL Execution 🔒
    • Strict query validation
    • SQL injection prevention
    • Comprehensive error handling and feedback
  • Query History 📚
    • Searchable query log
    • Query reusability
    • Multiple export formats (CSV, Excel, JSON)

🚀 Getting Started

graph LR
    A[User Input] --> B[Gemini Pro]
    B --> C[SQL Generator]
    C --> D[Database]
    D --> E[Results]
    E --> F[Visualization]
Loading

Installation

1️⃣ Clone the Repository

git clone https://github.com/yourusername/NLP2SQL.git
cd NLP2SQL

2️⃣ Set Up Environment

# Create .env file
cat << EOF > .env
GEMINI_API_KEY = "Your Google Gemini API Key"
GEMINI_MODEL = "Name of Gemini Model You Will be usin"
EOF

3️⃣ Install Dependencies

pip install -r requirements.txt

4️⃣ Launch the App

streamlit run app/NLP2SQL.py

🎨 Built With

Technology Purpose
Streamlit Web Interface
Google Gemini NLP Processing
PostgreSQL Database
Altair Visualizations

🌟 Key Features

mindmap
  root((NLP2SQL))
    Query Processing
      Natural Language Input
      Decision Logging
      Detailed Reasoning
    Visualization
      Interactive Charts
      Summary Statistics
      Data Distribution
    Database
      PostgreSQL
      SQLite
      Schema Analysis
    Security
      Query Validation
      Error Handling
      Safe Execution
Loading

💡 How It Works

  1. Query Input ➡️ User enters natural language query
  2. Processing ➡️ Gemini Pro analyzes and generates SQL with reasoning
  3. Validation ➡️ Query is validated for safety and correctness
  4. Execution ➡️ Query runs against selected database
  5. Analysis ➡️ Results are processed with summary statistics
  6. Visualization ➡️ Data is presented with AI-recommended charts
  7. Export ➡️ Results can be downloaded in multiple formats

📊 Supported Visualizations

  • Bar Chart: Comparing categorical data
  • Line Chart: Time-series and trend analysis
  • Scatter Plot: Relationship between variables
  • Area Chart: Cumulative totals and trends
  • Histogram: Distribution analysis

🔒 Security Features

  • Strict SQL query validation
  • Prevention of harmful SQL operations
  • Secure database connections
  • Protected sensitive information
  • Input sanitization

📈 Data Analysis

  • Comprehensive summary statistics
  • Distribution analysis
  • Correlation detection
  • Trend identification
  • Outlier detection

MIT License © Lohit Kolluri - feel free to use this project as you wish!

About

Transform natural language into SQL queries using Azure OpenAI. Visualize database results with interactive charts and explore data effortlessly.

Topics

Resources

Stars

Watchers

Forks

Languages