This project is an SQL Query Generator that automates the creation of SQL queries in two main steps:
- SQL Specification Generation
- Query Generation from Specification
It is modular, with dedicated components for each part of an SQL query (e.g., GROUP BY, HAVING, WHERE, JOIN, LIMIT, ORDER BY, etc.).
For more details, see Query_generator.pdf.
group_by_having: Modules for generating GROUP BY clauses.having: Modules for generating HAVING clauses.helper_funcs: Utility functions used across the project.join: Manages JOIN connections.limit: Generates LIMIT clauses.order_by: Generates ORDER BY clauses.output: Stores generated output files.read_schema: Reads schema details from files or databases.select_query: Generates SELECT clauses.subquery_generator: Generates subqueries.table_expression: Creates table expressions.where: Generates WHERE clauses.
config_file.json: Main configuration file for the project.config_file2.json: Use this configuration if you want to support set operations such asUNION,UNION ALL,INTERSECT,EXCEPT, andMINUS.query_generator_from_specifications.py: Generates queries from specified criteria.specification_generator_using_ht.py: Generates specifications using hash table.requirements.txt: Lists project dependencies.
output/farm.json: Example JSON specifications generated by the project.output/res.csv: Example CSV queries generated from specifications.
The project enables generation of SQL queries based on customizable specifications.
Each SQL clause is handled by a dedicated module, making the system extensible and easy to modify.
-
Configure the Project
- Edit
config_file.jsonto set your desired parameters and options. - If you want to support set operations like
UNION,UNION ALL,INTERSECT,EXCEPT, andMINUS, useconfig_file2.jsonas your configuration file.
- Edit
-
Install Dependencies and Run
pip install . pip install -r requirements.txt cd query_generation python3 query_generator_from_specifications.py
Generated queries and specifications are stored in the output folder.