The main.py
script in this project is a powerful tool for generating SQL queries from a given database schema and a user's question. It effectively utilizes the langchain_community
, langchain_core
, and Cohere
libraries to create a sophisticated language model. This model can accurately interpret the provided schema and question, and generate the corresponding SQL query with high precision. The script is designed to be user-friendly, prompting users for necessary inputs and seamlessly integrating with the environment variables for secure API token management.
Make sure you have the following dependencies installed:
langchain_community
langchain_core
python-dotenv
Cohere
StrOutputParser
ChatPromptTemplate
To use the SQL query generator, you need to set up your environment with the correct API keys and tokens. Here's how to do it:
-
Clone the repository:
git clone https://github.com/Namangupta123/SQL_Query_generator.git
-
Install the required dependencies:
pip install -r requirements.txt
-
Set up your
.env
file with the correct API keys and tokens. You can use the.env.example
file as a template. -
Write the schema for your database. Here is an example of how to write a schema:
Employees
- id(Varchar)
- name(Varchar)
- age(Int)
- Date_of_joining(Date)
- Salary(Int)
You can add more tables and columns as needed.
- Run the
main.py
script:
Contributions are welcome! If you find any issues or have suggestions for improvements, please open an issue or submit a pull request.