This project is a SQL query generator that uses a pre-trained language model (defog/sqlcoder-7b) to convert natural language questions into SQL queries. It is based on the Hugging Face Transformers library and generates SQL for a predefined database schema consisting of customers and orders tables.
The schema includes:
customers(id, name, country)orders(id, customer_id, amount, order_date)Clone or download the project to your local machine.
Create a virtual environment (recommended):
python -m venv .venv
source .venv/bin/activate # On Windows: .venv\Scripts\activate
Install the required dependencies:
pip install -r requirements.txt
Currently, the script loads the model and prints a success message. To generate SQL queries, you can modify the script or extend it.
Example usage in code:
from main import generate_sql
question = "What are the names of customers from the USA?"
sql = generate_sql(question)
print(sql)
build_prompt function. Modify it as needed for different schemas.This project does not specify a license. Please check with the original model providers for usage terms.
This project is a SQL query generator that uses a pre-trained language model (defog/sqlcoder-7b) to convert natural language questions into SQL queries. It is based on the Hugging Face Transformers library and generates SQL for a predefined database schema consisting of customers and orders tables.
The schema includes:
customers(id, name, country)orders(id, customer_id, amount, order_date)Clone or download the project to your local machine.
Create a virtual environment (recommended):
python -m venv .venv
source .venv/bin/activate # On Windows: .venv\Scripts\activate
Install the required dependencies:
pip install -r requirements.txt
Currently, the script loads the model and prints a success message. To generate SQL queries, you can modify the script or extend it.
Example usage in code:
from main import generate_sql
question = "What are the names of customers from the USA?"
sql = generate_sql(question)
print(sql)
build_prompt function. Modify it as needed for different schemas.This project does not specify a license. Please check with the original model providers for usage terms.