NL2SQL is a project that allows users to input natural language questions and it converts them into SQL queries. It visualizes the results in charts such as line graphs, bar charts, etc., and also generates summaries.
- Python 3.9+
- MySQL (or another relational database system)
- Clone the repository:
git clone https://github.com/yourusername/NL2SQL.git cd NL2SQL
- Create and activate a Python virtual environment:
python3 -m venv venv source venv/bin/activate # On Windows use `venv\Scripts\activate`
- Install the backend dependencies:
pip install -r requirements.txt
- Create a .env file at the root level for your environment variables. Make sure you add your database credentials here (e.g., database URL, API keys, etc.):
OPENAI_API_KEY=
- Run the backend server:
uvicorn app.main:app --reload
- The backend should now be running on http://127.0.0.1:8000.
To set up the MySQL database for the backend:
-
Install MySQL (if you haven't already):
- On macOS:
brew install mysql
- On Ubuntu:
sudo apt-get install mysql-server
- On Windows, you can download the MySQL installer from the official MySQL website.
- On macOS:
-
Start MySQL Server:
- On macOS:
brew services start mysql
- On Ubuntu:
sudo service mysql start
- On Windows, you can start the MySQL service from the Services menu.
- On macOS:
-
Login to MySQL:
mysql -u root -p
-
Create the database for the projectL:
CREATE DATABASE nl2sql;
-
Import the database schema (structure of tables, e.g. table.sql)::
mysql -u username -p nl2sql < path_to_table.sql
-
Import the data into the database (e.g. data.sql):
mysql -u username -p nl2sql < path_to_data.sql
-
Update your .env file with your MySQL credentials:
DB_HOST=localhost DB_PORT=3306 DB_USER=username DB_PASSWORD=password DB_NAME=nl2sql
- React + Vite
- NPM or Yarn
- Clone the repository:
git clone https://github.com/yourusername/NL2SQL.git cd NL2SQL/frontend
- Install the frontend dependencies:
npm install
- Run the frontend development server:
npm run dev
- The frontend should now be running on http://localhost:5173.