Skip to content

Namangupta123/SQL_Query_generator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

31 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SQL Query Generator

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.

Requirements

Make sure you have the following dependencies installed:

  • langchain_community
  • langchain_core
  • python-dotenv
  • Cohere
  • StrOutputParser
  • ChatPromptTemplate

Usage

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:

  1. Clone the repository:

    git clone https://github.com/Namangupta123/SQL_Query_generator.git
    
  2. Install the required dependencies:

    pip install -r requirements.txt
    
  3. Set up your .env file with the correct API keys and tokens. You can use the .env.example file as a template.

  4. 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.

  1. Run the main.py script:

Contributing

Contributions are welcome! If you find any issues or have suggestions for improvements, please open an issue or submit a pull request.

About

A bot to generate query for Your database.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages