SQLEyes is a CLI tool for analyzing simple, raw SQL queries for common sql anti-patterns.
This package can be installed using pip install sqleyes
. After installation, open a terminal and type sqleyes -h
to open a help guide showing all possible options and arguments.
$ sqleyes -h
usage: sqleyes [-h] -q
Analyze raw SQL queries for anti-patterns
optional arguments:
-h, --help show this help message and exit
-q , --query A raw SQL query to analyze
To analyze a query use the -q
flag with the query in string format.
$ sqleyes -q "SELECT * FROM product WHERE pCategory <> NULL"
[{"type": "Implict Columns", "detector_type": "anti-pattern"},
{"type": "Fear of the Unknown", "detector_type": "anti-pattern"}]
This package can also be imported into existing projects. Make sure it is installed in your project's virtual environment.
from sqleyes.utils.query_functions import check_single_value_rule
# Use a sqleyes function
has_single_values = check_single_value_rule(["AVG(price)"])
...
from sqleyes.main import main
# Check a query for anti-patterns
anti_patterns = main("SELECT * FROM product")
This repository contains the main SQLEyes package as well as the unit tests
- Make sure you have all the required packages installed. These can be found in
requirements.txt
andrequirements_dev.txt
. - Create a new feature branch
git checkout -b feature/<FEATURE NAME>
. - Install the package in editable mode using
pip install -e .
, which installs the package locally. Changes to the package a directly reflected in your environment. - (Optional) In order for the CLI tool to work in editable mode, run
pip install .
after step 3. - Implement the desired features.
- Write unit tests inside the
tests
directory. - Make sure all unit tests pass by running
pytest
in the root of the repository. - Make sure linting and static type hinting is proper by running
flake8 sqleyes tests
andmypy sqleyes
. - Create a pull request describing your feature.
- Make sure all tests passed, linting and static type hinting are proper (see steps 7 & 8 of Contribution).
- Increase version number accordingly.
- Run
python -m build
in the root directory. Adist
folder will be generated. - Upload the package to PyPI using Twine (
pip install twine
) using the following command:twine upload dist/*
.
This project was developed as a master's graduation project at Eindhoven University of Technology. Code boilerplate and best practices from best-practice-and-impact. This package depends on some of sqlparse features for parsing SQL queries.