Skip to main content

SQLEyes


Tests

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

  1. Make sure you have all the required packages installed. These can be found in requirements.txt and requirements_dev.txt.
  2. Create a new feature branch git checkout -b feature/<FEATURE NAME>.
  3. 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.
  4. (Optional) In order for the CLI tool to work in editable mode, run pip install . after step 3.
  5. Implement the desired features.
  6. Write unit tests inside the tests directory.
  7. Make sure all unit tests pass by running pytest in the root of the repository.
  8. Make sure linting and static type hinting is proper by running flake8 sqleyes tests and mypy sqleyes.
  9. Create a pull request describing your feature.

Building and distribution

  1. Make sure all tests passed, linting and static type hinting are proper (see steps 7 & 8 of Contribution).
  2. Increase version number accordingly.
  3. Run python -m build in the root directory. A dist folder will be generated.
  4. 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.

Metadata

Release files for sqleyes 0.5.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for sqleyes 0.5.0
File Size Uploaded
sqleyes-0.5.0.tar.gz 18.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for sqleyes 0.5.0
File Interpreter ABI Platform
sqleyes-0.5.0-py3-none-any.whl Python 3 none any Details

Total release size: 42.8 kB

Release files / sqleyes-0.5.0.tar.gz

Download URL sqleyes-0.5.0.tar.gz
Size 18.4 kB
Tags Source
SHA-256 checksum
How to use checksums
1b41750f590ecbeb598e54be30fc5de881a80e1b46d47764ca69d06c90b1ed7a
BLAKE2b-256 checksum
How to use checksums
4d97765fcbee29c526630f6c6a92c45ecc5a6b6c0cfaf2524ac6dc59d589a277
Upload date
Uploaded using Trusted Publishing?
What is 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

Release files / sqleyes-0.5.0-py3-none-any.whl

Download URL sqleyes-0.5.0-py3-none-any.whl
Size 24.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
abf2845bb3edbc9e09a7d384a4d6019e228f4c70f0703dbf3b62a8607e3d8dac
BLAKE2b-256 checksum
How to use checksums
032249472ac6f335485329e74499ebf40f9549679865a418c711df693e200a45
Upload date
Uploaded using Trusted Publishing?
What is 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

Release history Release notifications | RSS feed

This release

0.5.0 This release

2 release files

0.4.0

2 release files

0.3.1

2 release files

0.3.0

2 release files

0.2.9

2 release files

0.2.8

2 release files

0.2.7

2 release files

0.2.6

2 release files

0.2.5

2 release files

0.2.4

2 release files

0.2.3

2 release files

0.2.2

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page