Welcome to the SQL Compiler project! This project is designed to parse and compile SQL queries using a custom-built compiler with support for various SQL keywords and functions. This project includes lexical analysis, syntax analysis, and SQL query execution, providing extensive features for handling SQL operations.
- Lexical Analysis: Tokenizes SQL input into meaningful tokens.
- Syntax Analysis: Ensures that SQL queries conform to the grammar rules.
- SQL Keywords Support:
- One-word keywords:
DEFAULT
,UUID
,USER
, etc. - No-input keywords:
CURRENT_TIMESTAMP()
,NOW()
,SYSDATE()
, etc. - One-input keywords:
RAND(x)
, etc. - Two-input keywords:
CONCAT()
,POWER()
, etc. - Support for additional SQL functions and keywords based on custom input.
- One-word keywords:
- Error Handling: Provides clear error messages when invalid SQL syntax or keywords are detected.
- Customizable: Easily extendable with new SQL keywords and functions as needed.
- Comprehensive Parsing: Handles identifiers, keywords, and special SQL constructs.
- Interactive GUI: Includes a basic Tkinter-based interface for running SQL queries and displaying results.
- Extensibility: Add new SQL features or modify existing ones with ease.
- Error Reporting: Provides helpful error messages and identifies where syntax issues occur.
- Modular Design: Clean separation between lexical analysis, syntax analysis, and query execution.
- GUI Integration: Quickly test your SQL queries via a graphical interface.
- Testability: Includes test cases for validating SQL queries.
- Python 3.x: The main language used for development.
- Tkinter: Provides a simple GUI for testing and running SQL queries.
- Git: Version control to manage project progress and collaboration.
- LexicalAnalyzer: Custom lexical analyzer to tokenize SQL queries.
- SyntaxAnalyzer: Custom syntax analyzer for parsing SQL queries and ensuring compliance with SQL grammar.
- SQL Functions: Comprehensive support for built-in SQL functions and easy extension for custom functions.
-
Python 3.x: Make sure you have Python 3.x installed on your system. You can download it from here.
-
Git: Install Git to clone the repository. Download from here.
- Open your terminal or command prompt.
- Run the following command to clone the repository:
git clone https://github.com/amirrgb/SQL-Compiler-With-Python.git
- Navigate to the project directory:
cd SQL-Compiler-With-Python
You may need to install some Python dependencies. You can do this by running:
pip install -r requirements.txt
If requirements.txt
is not yet created, you can manually install any necessary packages (like Tkinter
or others) using pip
:
pip install tkinter
- Navigate to the project directory.
- Run the GUI using the following command:
python GUI.py
- You will see an interface where you can input SQL queries and test the output. For example, enter an
INSERT
query and see how the compiler processes it.
Here are some example queries that can be parsed and executed by the compiler:
-- One-word keyword
INSERT INTO your_table (column1) VALUES (DEFAULT);
-- No-input keyword
INSERT INTO your_table (column1) VALUES (CURRENT_TIMESTAMP());
-- One-input keyword
INSERT INTO your_table (column1) VALUES (UUID('your_uuid_here'));
-- Two-input keyword
INSERT INTO your_table (column1) VALUES (CONCAT('string1', 'string2'));
-- Two-input keyword with multiple values
INSERT INTO your_table (column1) VALUES (CONCAT('string1', 'string2', 'string3'));
The compiler includes detailed error reporting. If there are issues with syntax, such as missing parentheses or invalid SQL constructs, an error message will be shown in the console or GUI window.
Example error message:
SyntaxError: Expected identifier but found "123"
Contributions are welcome! Here's how you can contribute:
- Fork the repository.
- Create a new branch for your feature or bug fix:
git checkout -b feature-name
- Make your changes and commit them:
git commit -m "Add new feature"
- Push to your branch:
git push origin feature-name
- Create a pull request with a detailed description of your changes.
This project is licensed under the MIT License - see the LICENSE file for details.