Text-to-SQL application that leverages Google’s Gemini LLM to transform natural language input into SQL queries. The application reads a database schema, processes user inputs, and generates SQL queries to retrieve data based on those inputs. It is built with Python and Streamlit, making it suitable for both database management and natural language processing tasks.
Untitled.video.-.Made.with.Clipchamp.mp4
- Dynamic Database Connection: Connects to both SQL script files and SQLite databases, dynamically retrieving table schemas.
- Text-to-SQL Query Generation: Generates SQL queries using Gemini LLM based on user-inputted natural language queries.
- Schema Visualization: Displays database schema in a user-friendly layout with tables, columns, and data types.
- Customizable UI: Streamlit-based interface with dark theme support for enhanced user experience.
-
Clone the repository:
git clone https://github.com/abhi526691/ATS-Resume- cd Text-To-SQL-LLM
-
Install the required packages:
pip install -r requirements.txt
-
Set up the environment variables by creating a
.env
file and adding your Google Gemini API key:
Get Your API KEY from GeminiGOOGLE_API_KEY=your_google_api_key
-
Run the application with the following command:
streamlit run main.py
-
Upload a database file (.sql or .db) using the UI file uploader.
-
Enter a natural language query describing the data you wish to retrieve from the database.
-
View the generated SQL query and its results.
Contains the primary application code, initializing the database schema, generating SQL queries, and displaying the schema diagram.
Defines the View
class, which provides methods for rendering UI elements in Streamlit, processing user input, and applying custom styles.
Handles database management, including loading SQL files or SQLite databases, executing SQL queries, and retrieving schema information.
Responsible for retrieving and transforming the schema, including visual representation in Streamlit.
Contains the logic for generating SQL queries from natural language input using the Google Gemini model.
-
Launch the application and upload a
.db
or.sql
file. -
Enter a query, such as:
- "Show me all user details with active status."
- "Retrieve the top 5 orders sorted by date."
-
The system will use the Gemini LLM to generate the SQL query based on the database schema and execute it, displaying the results.
- Google Gemini LLM: Used for text-to-SQL query generation.
- Streamlit: Provides the web interface for the application.
Abhishek Pandey |
This project demonstrates a powerful integration of LLMs with SQL databases, making it easy to retrieve data without needing in-depth knowledge of SQL syntax.