Inspiration
The inspiration for NLP2SQL came from recognizing the barriers non-technical users face when interacting with databases. SQL expertise is often required for retrieving and analyzing data, slowing down workflows for business analysts, researchers, and anyone without coding knowledge. We wanted to create a tool that democratizes data access by allowing users to query databases using plain English, turning questions directly into actionable insights.
What it does
NLP2SQL is an app that converts natural language questions into SQL queries, allowing users to retrieve and analyze data without writing any code. Users can type in questions like "Show total sales by region," and the app generates SQL code, retrieves the data, and presents it in easy-to-understand visualizations. It also offers dynamic visualization suggestions based on query results, schema exploration, query history, and multiple export options for seamless integration with other workflows.
How we built it
We built NLP2SQL using:
- Streamlit for the interactive web interface.
- Azure OpenAI and GPT-3.5 Turbo to process natural language inputs and generate accurate SQL queries.
- SQLite and PostgreSQL for database support.
- Pandas for data manipulation and processing.
- Altair for creating data visualizations.
Each component was integrated to provide a user-friendly experience, from processing natural language inputs to dynamically generating visual insights.
Challenges we ran into
A major challenge was ensuring that SQL queries generated from natural language were both accurate and aligned with the database schema. This required iterative fine-tuning of the NLP model and adding validation checks. Another challenge was optimizing the user interface to support interactive schema exploration while remaining intuitive for non-technical users. These hurdles were addressed by enhancing the backend’s robustness and implementing clear, guided UI elements.
Accomplishments that we're proud of
We’re proud of creating a tool that makes data accessible to everyone, regardless of technical expertise. The successful integration of dynamic visualizations and an easy-to-use interface was also a significant achievement. Additionally, implementing an audit trail for query history was an accomplishment that adds both functionality and transparency to the app, improving usability for both casual and frequent users.
What we learned
This project taught us the complexities of natural language processing in real-world applications. We learned how to balance technical depth with user accessibility, ensuring that the app remains powerful yet easy to use. We also gained valuable insights into effective data visualization, understanding how to present data meaningfully based on the query context.
What's next for NLP2SQL
Moving forward, we aim to enhance NLP2SQL by:
- Incorporating additional database support (e.g., MySQL, Oracle).
- Adding more visualization types and customization options.
- Implementing machine learning-based query optimization to improve response accuracy and speed.
- Extending accessibility with mobile and desktop app versions.
These future developments will further empower users to make data-driven decisions swiftly and confidently.
Built With
- altair
- azure-openai
- gpt-3.5
- pandas
- postgresql
- sqlite
- streamlit
Log in or sign up for Devpost to join the conversation.