NaturalQuery Executor is a sophisticated tool designed to simplify interactions with databases by converting natural language queries into executable SQL commands. It not only generates SQL queries from user inputs but also directly executes them on the connected database and returns the results. This project integrates advanced AI models with database management, offering a seamless way to interact with and manipulate data.
- Natural Language Processing: Converts user queries in natural language into SQL commands.
- Direct Database Interaction: Executes SQL queries directly on the database and returns results.
- Dynamic Query Execution: Handles various types of SQL commands including SELECT, INSERT, UPDATE, and DELETE.
- User-Friendly Interface: Provides a conversational interface for easy interaction and query execution.
This module contains the Text_to_query class which:
- Loads and configures an AI model for text-to-SQL conversion.
- Converts natural language inputs into SQL queries.
This module contains the Query_execution class which:
- Connects to a SQLite database.
- Executes SQL queries and returns results or success messages.
This module:
- Integrates
Text_to_queryandQuery_executioninto a user-friendly application using Chainlit. - Handles user interactions, generates SQL queries, executes them, and displays results.
To set up the Text-to-SQL Converter, follow these steps:
- Clone the repository:
git clone https://github.com/majipa007/NaturalQuery-Executor-Using-Phi-3.git
cd NaturalQuery-Executor-Using-Phi-3
- Install dependencies:
pip install -r requirements.txt
To launch the application:
- Run the following command:
chainlit run app.py -w
-
Open a web browser and navigate to
http://localhost:8000 -
Input your query in natural language in the chat interface
-
The system will generate and execute the corresponding SQL query
The Text-to-SQL Converter is built on the following technologies:
- Hugging Face Transformers
- Chainlit
- Python
- SQLite
Key components include:
- Text_to_database Class: Manages model initialization, query generation, and database operations
- Chainlit Integration: Provides the interactive user interface
- Query Processing Pipeline: Handles natural language input, SQL generation, and query execution
We welcome contributions to the Text-to-SQL Converter project.
This project is licensed under the MIT License.
We extend our gratitude to the developers and researchers behind the language model (Microsoft and Unsloth), Dataset (https://huggingface.co/b-mc2) and libraries that power this application.
