A CLI in Python that analyzes raw SQL queries for common anti-patterns
Project description
About SQLEyes
SQLEyes is a CLI tool for analyzing simple, raw SQL queries for common sql anti-patterns.
Usage
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")
Repository
This repository contains the main SQLEyes package as well as the unit tests
Contributing
- Make sure you have all the required packages installed. These can be found in
requirements.txtandrequirements_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
testsdirectory. - Make sure all unit tests pass by running
pytestin the root of the repository. - Make sure linting and static type hinting is proper by running
flake8 sqleyes testsandmypy sqleyes. - Create a pull request describing your feature.
Building and distribution
- 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 buildin the root directory. Adistfolder will be generated. - Upload the package to PyPI using Twine (
pip install twine) using the following command:twine upload dist/*.
Acknowledgements
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.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file sqleyes-0.5.0.tar.gz.
File metadata
- Download URL: sqleyes-0.5.0.tar.gz
- Upload date:
- Size: 18.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/33.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.63.0 importlib-metadata/4.11.2 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.8.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1b41750f590ecbeb598e54be30fc5de881a80e1b46d47764ca69d06c90b1ed7a
|
|
| MD5 |
47335c7616c9a36918bc1f29774793e3
|
|
| BLAKE2b-256 |
4d97765fcbee29c526630f6c6a92c45ecc5a6b6c0cfaf2524ac6dc59d589a277
|
File details
Details for the file sqleyes-0.5.0-py3-none-any.whl.
File metadata
- Download URL: sqleyes-0.5.0-py3-none-any.whl
- Upload date:
- Size: 24.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/33.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.63.0 importlib-metadata/4.11.2 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.8.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
abf2845bb3edbc9e09a7d384a4d6019e228f4c70f0703dbf3b62a8607e3d8dac
|
|
| MD5 |
8499dd0566f90cf422282c254e92b7e3
|
|
| BLAKE2b-256 |
032249472ac6f335485329e74499ebf40f9549679865a418c711df693e200a45
|