Metadata-Version: 2.1
Name: sqleyes
Version: 0.2.1
Summary: A CLI in Python that analyzes raw SQL queries for common anti-patterns
Home-page: https://leonardomathon.nl
Author: Leonardo Mathon
Author-email: info@leonardomathon.nl
License: MIT
Keywords: SQL,anti-patterns,analysis
Platform: unix
Platform: linux
Platform: osx
Platform: cygwin
Platform: win32
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.6
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Requires-Python: >=3.6
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: sqlparse (>=0.4.2)
Requires-Dist: rich (>=12.0.0)
Provides-Extra: testing
Requires-Dist: pytest (>=7.0) ; extra == 'testing'
Requires-Dist: pytest-cov (>=3.0) ; extra == 'testing'
Requires-Dist: mypy (>=0.910) ; extra == 'testing'
Requires-Dist: types-setuptools (>=57.4.10) ; extra == 'testing'
Requires-Dist: flake8 (>=4.0) ; extra == 'testing'
Requires-Dist: tox (>=3.24) ; extra == 'testing'

<p align="center">
<img src="https://raw.githubusercontent.com/leonardomathon/sqleyes/develop/design/logo-combined.svg" alt="SQLEyes" title="SQLEyes logo" style="max-width:100%; width:60%">
</p>

---

![Tests](https://github.com/mCodingLLC/SlapThatLikeButton-TestingStarterProject/actions/workflows/tests.yml/badge.svg)

## 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.

```console
$ 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.

```console
$ 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.

```Python
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](#Contributing)).
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](https://github.com/best-practice-and-impact/example-package-python).
> This package depends on some of [sqlparse](https://pypi.org/project/sqlparse/) features for parsing SQL queries.


