Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/adriamontoto/criteria-pattern
The "Criteria Pattern" is a Python 🐍 package that simplifies and standardizes criteria based filtering 🤏🏻, validation and selection.
https://github.com/adriamontoto/criteria-pattern
criteria development filtering pattern python python3 python311 python312 python313 selection sql tools utilities validation
Last synced: 3 months ago
JSON representation
The "Criteria Pattern" is a Python 🐍 package that simplifies and standardizes criteria based filtering 🤏🏻, validation and selection.
- Host: GitHub
- URL: https://github.com/adriamontoto/criteria-pattern
- Owner: adriamontoto
- License: mit
- Created: 2024-08-12T19:40:53.000Z (6 months ago)
- Default Branch: master
- Last Pushed: 2024-11-15T16:50:51.000Z (3 months ago)
- Last Synced: 2024-11-15T17:39:27.647Z (3 months ago)
- Topics: criteria, development, filtering, pattern, python, python3, python311, python312, python313, selection, sql, tools, utilities, validation
- Language: Python
- Homepage: https://pypi.org/project/criteria-pattern/
- Size: 108 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
- Security: SECURITY.md
Awesome Lists containing this project
README
# 🤏🏻 Criteria Pattern
The "Criteria Pattern" is a Python 🐍 package that simplifies and standardizes criteria based filtering 🤏🏻, validation and selection. This package provides a set of prebuilt 👷🏻 objects and utilities that you can drop into your existing projects and not have to implement yourself.
These utilities 🛠️ are useful when you need complex filtering logic. It also enforces 👮🏻 best practices so all your filtering processes follow a uniform standard.
Easy to install and integrate, this is a must have for any Python developer looking to simplify their workflow, enforce design patterns and use the full power of modern ORMs and SQL 🗄️ in their projects 🚀.
## Table of Contents
- [📥 Installation](#installation)
- [🔑 License](#license)
- [💻 Utilization](#utilization)
## 📥 Installation
```bash
pip install criteria-pattern
``````python
from criteria_pattern import Criteria, Filter, FilterOperator
from criteria_pattern.converter import SqlConverteris_adult = Criteria(filters=[Filter('age', FilterOperator.GREATER_OR_EQUAL, 18)])
email_is_gmail = Criteria(filters=[Filter('email', FilterOperator.ENDS_WITH, '@gmail.com')])
email_is_yahoo = Criteria(filters=[Filter('email', FilterOperator.ENDS_WITH, '@yahoo.com')])query = SqlConverter.convert(criteria=is_adult & (email_is_gmail | email_is_yahoo), table='user')
print(query)
# >>> SELECT * FROM user WHERE (age >= '18' AND (email LIKE '%@gmail.com' OR email LIKE '%@yahoo.com'));
```
## 🔑 License
This project is licensed under the terms of the [MIT license](https://choosealicense.com/licenses/mit/).