mbu-dev-shared-components 1.1.0__tar.gz → 1.2.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {mbu_dev_shared_components-1.1.0 → mbu_dev_shared_components-1.2.1}/LICENSE +21 -21
- {mbu_dev_shared_components-1.1.0 → mbu_dev_shared_components-1.2.1}/PKG-INFO +84 -83
- {mbu_dev_shared_components-1.1.0 → mbu_dev_shared_components-1.2.1}/README.md +60 -60
- {mbu_dev_shared_components-1.1.0 → mbu_dev_shared_components-1.2.1}/mbu_dev_shared_components/database/constants.py +131 -131
- {mbu_dev_shared_components-1.1.0 → mbu_dev_shared_components-1.2.1}/mbu_dev_shared_components/database/logging.py +85 -85
- {mbu_dev_shared_components-1.1.0 → mbu_dev_shared_components-1.2.1}/mbu_dev_shared_components/database/utility.py +43 -43
- {mbu_dev_shared_components-1.1.0 → mbu_dev_shared_components-1.2.1}/mbu_dev_shared_components/getorganized/auth.py +21 -21
- {mbu_dev_shared_components-1.1.0 → mbu_dev_shared_components-1.2.1}/mbu_dev_shared_components/getorganized/cases.py +90 -90
- {mbu_dev_shared_components-1.1.0 → mbu_dev_shared_components-1.2.1}/mbu_dev_shared_components/getorganized/contacts.py +32 -32
- {mbu_dev_shared_components-1.1.0 → mbu_dev_shared_components-1.2.1}/mbu_dev_shared_components/getorganized/documents.py +194 -194
- {mbu_dev_shared_components-1.1.0 → mbu_dev_shared_components-1.2.1}/mbu_dev_shared_components/getorganized/objects.py +176 -176
- {mbu_dev_shared_components-1.1.0 → mbu_dev_shared_components-1.2.1}/mbu_dev_shared_components/google/api/auth.py +134 -134
- {mbu_dev_shared_components-1.1.0 → mbu_dev_shared_components-1.2.1}/mbu_dev_shared_components/google/workspace/alerts.py +53 -53
- {mbu_dev_shared_components-1.1.0 → mbu_dev_shared_components-1.2.1}/mbu_dev_shared_components/msoffice365/excel/excel_reader.py +228 -228
- {mbu_dev_shared_components-1.1.0 → mbu_dev_shared_components-1.2.1}/mbu_dev_shared_components/msoffice365/sharepoint_api/files.py +251 -251
- {mbu_dev_shared_components-1.1.0 → mbu_dev_shared_components-1.2.1}/mbu_dev_shared_components/os2forms/documents.py +26 -26
- {mbu_dev_shared_components-1.1.0 → mbu_dev_shared_components-1.2.1}/mbu_dev_shared_components/os2forms/forms.py +66 -66
- {mbu_dev_shared_components-1.1.0 → mbu_dev_shared_components-1.2.1}/mbu_dev_shared_components/romexis/db_handler.py +189 -137
- mbu_dev_shared_components-1.2.1/mbu_dev_shared_components/romexis/helper_functions.py +158 -0
- {mbu_dev_shared_components-1.1.0 → mbu_dev_shared_components-1.2.1}/mbu_dev_shared_components/sap/create_invoice.py +198 -198
- {mbu_dev_shared_components-1.1.0 → mbu_dev_shared_components-1.2.1}/mbu_dev_shared_components/solteqtand/app_handler.py +1668 -1668
- {mbu_dev_shared_components-1.1.0 → mbu_dev_shared_components-1.2.1}/mbu_dev_shared_components/solteqtand/db_handler.py +338 -338
- {mbu_dev_shared_components-1.1.0 → mbu_dev_shared_components-1.2.1}/mbu_dev_shared_components/solteqtand/helper_functions.py +107 -107
- {mbu_dev_shared_components-1.1.0 → mbu_dev_shared_components-1.2.1}/mbu_dev_shared_components/utils/db_stored_procedure_executor.py +72 -72
- {mbu_dev_shared_components-1.1.0 → mbu_dev_shared_components-1.2.1}/mbu_dev_shared_components/utils/fernet_encryptor.py +65 -65
- {mbu_dev_shared_components-1.1.0 → mbu_dev_shared_components-1.2.1}/mbu_dev_shared_components/utils/file_handler.py +33 -33
- {mbu_dev_shared_components-1.1.0 → mbu_dev_shared_components-1.2.1}/mbu_dev_shared_components/utils/json_handler.py +102 -102
- {mbu_dev_shared_components-1.1.0 → mbu_dev_shared_components-1.2.1}/mbu_dev_shared_components.egg-info/PKG-INFO +84 -83
- {mbu_dev_shared_components-1.1.0 → mbu_dev_shared_components-1.2.1}/mbu_dev_shared_components.egg-info/SOURCES.txt +2 -2
- {mbu_dev_shared_components-1.1.0 → mbu_dev_shared_components-1.2.1}/mbu_dev_shared_components.egg-info/requires.txt +1 -0
- {mbu_dev_shared_components-1.1.0 → mbu_dev_shared_components-1.2.1}/pyproject.toml +31 -30
- {mbu_dev_shared_components-1.1.0 → mbu_dev_shared_components-1.2.1}/setup.cfg +4 -4
- mbu_dev_shared_components-1.1.0/tests/test_database.py +0 -0
- {mbu_dev_shared_components-1.1.0 → mbu_dev_shared_components-1.2.1}/mbu_dev_shared_components/database/__init__.py +0 -0
- {mbu_dev_shared_components-1.1.0 → mbu_dev_shared_components-1.2.1}/mbu_dev_shared_components/getorganized/__init__.py +0 -0
- {mbu_dev_shared_components-1.1.0 → mbu_dev_shared_components-1.2.1}/mbu_dev_shared_components/google/__init__.py +0 -0
- {mbu_dev_shared_components-1.1.0 → mbu_dev_shared_components-1.2.1}/mbu_dev_shared_components/google/api/__init__.py +0 -0
- {mbu_dev_shared_components-1.1.0 → mbu_dev_shared_components-1.2.1}/mbu_dev_shared_components/google/workspace/__init__.py +0 -0
- {mbu_dev_shared_components-1.1.0 → mbu_dev_shared_components-1.2.1}/mbu_dev_shared_components/msoffice365/__init__.py +0 -0
- {mbu_dev_shared_components-1.1.0 → mbu_dev_shared_components-1.2.1}/mbu_dev_shared_components/msoffice365/excel/__init__.py +0 -0
- {mbu_dev_shared_components-1.1.0 → mbu_dev_shared_components-1.2.1}/mbu_dev_shared_components/msoffice365/sharepoint_api/__init__.py +0 -0
- {mbu_dev_shared_components-1.1.0 → mbu_dev_shared_components-1.2.1}/mbu_dev_shared_components/os2forms/__init__.py +0 -0
- {mbu_dev_shared_components-1.1.0 → mbu_dev_shared_components-1.2.1}/mbu_dev_shared_components/romexis/__init__.py +0 -0
- {mbu_dev_shared_components-1.1.0 → mbu_dev_shared_components-1.2.1}/mbu_dev_shared_components/sap/__init__.py +0 -0
- {mbu_dev_shared_components-1.1.0 → mbu_dev_shared_components-1.2.1}/mbu_dev_shared_components/solteqtand/__init__.py +0 -0
- {mbu_dev_shared_components-1.1.0 → mbu_dev_shared_components-1.2.1}/mbu_dev_shared_components/utils/__init__.py +0 -0
- {mbu_dev_shared_components-1.1.0 → mbu_dev_shared_components-1.2.1}/mbu_dev_shared_components.egg-info/dependency_links.txt +0 -0
- {mbu_dev_shared_components-1.1.0 → mbu_dev_shared_components-1.2.1}/mbu_dev_shared_components.egg-info/top_level.txt +0 -0
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2024 AAK-MBU
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 AAK-MBU
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -1,83 +1,84 @@
|
|
|
1
|
-
Metadata-Version: 2.4
|
|
2
|
-
Name: mbu_dev_shared_components
|
|
3
|
-
Version: 1.1
|
|
4
|
-
Summary: Shared components to use in RPA projects
|
|
5
|
-
Author-email: MBU <rpa@mbu.aarhus.dk>
|
|
6
|
-
Classifier: Programming Language :: Python :: 3
|
|
7
|
-
Classifier: License :: OSI Approved :: MIT License
|
|
8
|
-
Classifier: Operating System :: Microsoft :: Windows
|
|
9
|
-
Requires-Python: >=3.7
|
|
10
|
-
Description-Content-Type: text/markdown
|
|
11
|
-
License-File: LICENSE
|
|
12
|
-
Requires-Dist: openpyxl>=3.1.2
|
|
13
|
-
Requires-Dist: pyodbc>=5.1.0
|
|
14
|
-
Requires-Dist: requests_ntlm>=1.2.0
|
|
15
|
-
Requires-Dist: python-dateutil==2.9.*
|
|
16
|
-
Requires-Dist: cryptography>=43.0.0
|
|
17
|
-
Requires-Dist: office365-rest-python-client
|
|
18
|
-
Requires-Dist: uiautomation
|
|
19
|
-
Requires-Dist: pillow
|
|
20
|
-
Requires-Dist: psutil
|
|
21
|
-
Requires-Dist: docx2pdf
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
[](https://badge.fury.io/py/mbu-dev-shared-components)
|
|
28
|
+
[](https://opensource.org/licenses/MIT)
|
|
29
|
+
|
|
30
|
+
## Overview
|
|
31
|
+
|
|
32
|
+
MBU Dev Shared Components is a Python library that provides helper modules to streamline Robotic Process Automation (RPA) development.
|
|
33
|
+
|
|
34
|
+
## Features
|
|
35
|
+
|
|
36
|
+
- **Office365 Integration**:
|
|
37
|
+
- SharePoint
|
|
38
|
+
- Excel
|
|
39
|
+
- **SAP Integration**
|
|
40
|
+
- **Solteq Tand Integration**
|
|
41
|
+
- **Utility Modules**:
|
|
42
|
+
- JSON handling
|
|
43
|
+
- Fernet encryption
|
|
44
|
+
|
|
45
|
+
## Installation
|
|
46
|
+
|
|
47
|
+
Install the package using pip:
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
pip install mbu-dev-shared-components
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
# Dynamic SQL Query Builder
|
|
54
|
+
|
|
55
|
+
This repository provides a **generic function** to dynamically build SQL `WHERE` clauses using filters. It supports:
|
|
56
|
+
|
|
57
|
+
- **Equality (`=`)**
|
|
58
|
+
- **LIKE (`%search%`)**
|
|
59
|
+
- **IN (`column IN (value1, value2, ...)`)**
|
|
60
|
+
- **BETWEEN (`column BETWEEN value1 AND value2`)**
|
|
61
|
+
- **AND & OR Conditions**
|
|
62
|
+
- **ORDER BY (`ORDER BY column ASC/DESC`)**
|
|
63
|
+
|
|
64
|
+
---
|
|
65
|
+
|
|
66
|
+
## 📌 How to Use the `check_if_event_exists` Function
|
|
67
|
+
|
|
68
|
+
| **Usage Type** | **Example Function Call** | **Generated SQL WHERE Clause** |
|
|
69
|
+
|--------------|--------------------------------------|--------------------------------------------|
|
|
70
|
+
| **1. Basic Equality Filtering** | ```python self.check_if_event_exists(filters={"p.cpr": "123456-7890", "e.event_name": "Some Clinic"}) ``` | `WHERE 1=1 AND p.cpr = ? AND e.event_name = ?` |
|
|
71
|
+
| **2. LIKE Filtering** (Partial Match) | ```python self.check_if_event_exists(filters={"e.event_name": "%Clinic%"}) ``` | `WHERE 1=1 AND e.event_name LIKE ?` |
|
|
72
|
+
| **3. IN Filtering** (Multiple Values) | ```python self.check_if_event_exists(filters={"e.event_message": ["Scheduled", "Pending"]}) ``` | `WHERE 1=1 AND e.event_message IN (?, ?)` |
|
|
73
|
+
| **4. BETWEEN Filtering** (Range) | ```python self.check_if_event_exists(filters={"e.eventTriggerDate": ("2024-01-01", "2024-12-31")}) ``` | `WHERE 1=1 AND e.eventTriggerDate BETWEEN ? AND ?` |
|
|
74
|
+
| **5. Multiple AND Conditions** | ```python self.check_if_event_exists(filters={"p.cpr": "123456-7890", "e.event_message": "Scheduled", "e.archived": 0}) ``` | `WHERE 1=1 AND p.cpr = ? AND e.event_message = ? AND e.archived = ?` |
|
|
75
|
+
| **6. OR Conditions (Single Group)** | ```python self.check_if_event_exists(or_filters=[{"e.event_name": "Clinic A"}, {"e.event_name": "Clinic B"}]) ``` | `WHERE 1=1 AND (e.event_name = ? OR e.event_name = ?)` |
|
|
76
|
+
| **7. OR with Multiple Conditions** | ```python self.check_if_event_exists(or_filters=[{"e.event_name": "Clinic A", "e.event_message": "Scheduled"}, {"e.event_name": "Clinic B"}]) ``` | `WHERE 1=1 AND ((e.event_name = ? AND e.event_message = ?) OR (e.event_name = ?))` |
|
|
77
|
+
| **8. AND & OR Combined** | ```python self.check_if_event_exists(filters={"e.archived": 0}, or_filters=[{"e.event_name": "Clinic A"}, {"e.event_name": "Clinic B"}]) ``` | `WHERE 1=1 AND e.archived = ? AND (e.event_name = ? OR e.event_name = ?)` |
|
|
78
|
+
| **9. LIKE with OR** | ```python self.check_if_event_exists(or_filters=[{"e.event_message": "%Scheduled%"}, {"e.event_message": "%Pending%"}]) ``` | `WHERE 1=1 AND (e.event_message LIKE ? OR e.event_message LIKE ?)` |
|
|
79
|
+
| **10. Complex AND, OR, LIKE, IN Combined** | ```python self.check_if_event_exists(filters={"p.cpr": "123456-7890", "e.event_message": ["Scheduled", "Pending"]}, or_filters=[{"e.event_name": "%Hospital%"}, {"e.event_name": "%Clinic%"}]) ``` | `WHERE 1=1 AND p.cpr = ? AND e.event_message IN (?, ?) AND (e.event_name LIKE ? OR e.event_name LIKE ?)` |
|
|
80
|
+
| **11. ORDER BY (Ascending)** | ```python self.check_if_event_exists(filters={"p.cpr": "123456-7890"}, order_by="e.timestamp", order_direction="ASC") ``` | `WHERE 1=1 AND p.cpr = ? ORDER BY e.timestamp ASC` |
|
|
81
|
+
| **12. ORDER BY (Descending)** | ```python self.check_if_event_exists(filters={"p.cpr": "123456-7890"}, order_by="e.timestamp", order_direction="DESC") ``` | `WHERE 1=1 AND p.cpr = ? ORDER BY e.timestamp DESC` |
|
|
82
|
+
| **13. ORDER BY with Multiple Filters** | ```python self.check_if_event_exists(filters={"e.event_message": "Scheduled"}, order_by="e.eventTriggerDate", order_direction="DESC") ``` | `WHERE 1=1 AND e.event_message = ? ORDER BY e.eventTriggerDate DESC` |
|
|
83
|
+
=======
|
|
84
|
+
```
|
|
@@ -1,60 +1,60 @@
|
|
|
1
|
-
# MBU Dev Shared Components
|
|
2
|
-
|
|
3
|
-
[](https://badge.fury.io/py/mbu-dev-shared-components)
|
|
4
|
-
[](https://opensource.org/licenses/MIT)
|
|
5
|
-
|
|
6
|
-
## Overview
|
|
7
|
-
|
|
8
|
-
MBU Dev Shared Components is a Python library that provides helper modules to streamline Robotic Process Automation (RPA) development.
|
|
9
|
-
|
|
10
|
-
## Features
|
|
11
|
-
|
|
12
|
-
- **Office365 Integration**:
|
|
13
|
-
- SharePoint
|
|
14
|
-
- Excel
|
|
15
|
-
- **SAP Integration**
|
|
16
|
-
- **Solteq Tand Integration**
|
|
17
|
-
- **Utility Modules**:
|
|
18
|
-
- JSON handling
|
|
19
|
-
- Fernet encryption
|
|
20
|
-
|
|
21
|
-
## Installation
|
|
22
|
-
|
|
23
|
-
Install the package using pip:
|
|
24
|
-
|
|
25
|
-
```bash
|
|
26
|
-
pip install mbu-dev-shared-components
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
# Dynamic SQL Query Builder
|
|
30
|
-
|
|
31
|
-
This repository provides a **generic function** to dynamically build SQL `WHERE` clauses using filters. It supports:
|
|
32
|
-
|
|
33
|
-
- **Equality (`=`)**
|
|
34
|
-
- **LIKE (`%search%`)**
|
|
35
|
-
- **IN (`column IN (value1, value2, ...)`)**
|
|
36
|
-
- **BETWEEN (`column BETWEEN value1 AND value2`)**
|
|
37
|
-
- **AND & OR Conditions**
|
|
38
|
-
- **ORDER BY (`ORDER BY column ASC/DESC`)**
|
|
39
|
-
|
|
40
|
-
---
|
|
41
|
-
|
|
42
|
-
## 📌 How to Use the `check_if_event_exists` Function
|
|
43
|
-
|
|
44
|
-
| **Usage Type** | **Example Function Call** | **Generated SQL WHERE Clause** |
|
|
45
|
-
|--------------|--------------------------------------|--------------------------------------------|
|
|
46
|
-
| **1. Basic Equality Filtering** | ```python self.check_if_event_exists(filters={"p.cpr": "123456-7890", "e.event_name": "Some Clinic"}) ``` | `WHERE 1=1 AND p.cpr = ? AND e.event_name = ?` |
|
|
47
|
-
| **2. LIKE Filtering** (Partial Match) | ```python self.check_if_event_exists(filters={"e.event_name": "%Clinic%"}) ``` | `WHERE 1=1 AND e.event_name LIKE ?` |
|
|
48
|
-
| **3. IN Filtering** (Multiple Values) | ```python self.check_if_event_exists(filters={"e.event_message": ["Scheduled", "Pending"]}) ``` | `WHERE 1=1 AND e.event_message IN (?, ?)` |
|
|
49
|
-
| **4. BETWEEN Filtering** (Range) | ```python self.check_if_event_exists(filters={"e.eventTriggerDate": ("2024-01-01", "2024-12-31")}) ``` | `WHERE 1=1 AND e.eventTriggerDate BETWEEN ? AND ?` |
|
|
50
|
-
| **5. Multiple AND Conditions** | ```python self.check_if_event_exists(filters={"p.cpr": "123456-7890", "e.event_message": "Scheduled", "e.archived": 0}) ``` | `WHERE 1=1 AND p.cpr = ? AND e.event_message = ? AND e.archived = ?` |
|
|
51
|
-
| **6. OR Conditions (Single Group)** | ```python self.check_if_event_exists(or_filters=[{"e.event_name": "Clinic A"}, {"e.event_name": "Clinic B"}]) ``` | `WHERE 1=1 AND (e.event_name = ? OR e.event_name = ?)` |
|
|
52
|
-
| **7. OR with Multiple Conditions** | ```python self.check_if_event_exists(or_filters=[{"e.event_name": "Clinic A", "e.event_message": "Scheduled"}, {"e.event_name": "Clinic B"}]) ``` | `WHERE 1=1 AND ((e.event_name = ? AND e.event_message = ?) OR (e.event_name = ?))` |
|
|
53
|
-
| **8. AND & OR Combined** | ```python self.check_if_event_exists(filters={"e.archived": 0}, or_filters=[{"e.event_name": "Clinic A"}, {"e.event_name": "Clinic B"}]) ``` | `WHERE 1=1 AND e.archived = ? AND (e.event_name = ? OR e.event_name = ?)` |
|
|
54
|
-
| **9. LIKE with OR** | ```python self.check_if_event_exists(or_filters=[{"e.event_message": "%Scheduled%"}, {"e.event_message": "%Pending%"}]) ``` | `WHERE 1=1 AND (e.event_message LIKE ? OR e.event_message LIKE ?)` |
|
|
55
|
-
| **10. Complex AND, OR, LIKE, IN Combined** | ```python self.check_if_event_exists(filters={"p.cpr": "123456-7890", "e.event_message": ["Scheduled", "Pending"]}, or_filters=[{"e.event_name": "%Hospital%"}, {"e.event_name": "%Clinic%"}]) ``` | `WHERE 1=1 AND p.cpr = ? AND e.event_message IN (?, ?) AND (e.event_name LIKE ? OR e.event_name LIKE ?)` |
|
|
56
|
-
| **11. ORDER BY (Ascending)** | ```python self.check_if_event_exists(filters={"p.cpr": "123456-7890"}, order_by="e.timestamp", order_direction="ASC") ``` | `WHERE 1=1 AND p.cpr = ? ORDER BY e.timestamp ASC` |
|
|
57
|
-
| **12. ORDER BY (Descending)** | ```python self.check_if_event_exists(filters={"p.cpr": "123456-7890"}, order_by="e.timestamp", order_direction="DESC") ``` | `WHERE 1=1 AND p.cpr = ? ORDER BY e.timestamp DESC` |
|
|
58
|
-
| **13. ORDER BY with Multiple Filters** | ```python self.check_if_event_exists(filters={"e.event_message": "Scheduled"}, order_by="e.eventTriggerDate", order_direction="DESC") ``` | `WHERE 1=1 AND e.event_message = ? ORDER BY e.eventTriggerDate DESC` |
|
|
59
|
-
=======
|
|
60
|
-
```
|
|
1
|
+
# MBU Dev Shared Components
|
|
2
|
+
|
|
3
|
+
[](https://badge.fury.io/py/mbu-dev-shared-components)
|
|
4
|
+
[](https://opensource.org/licenses/MIT)
|
|
5
|
+
|
|
6
|
+
## Overview
|
|
7
|
+
|
|
8
|
+
MBU Dev Shared Components is a Python library that provides helper modules to streamline Robotic Process Automation (RPA) development.
|
|
9
|
+
|
|
10
|
+
## Features
|
|
11
|
+
|
|
12
|
+
- **Office365 Integration**:
|
|
13
|
+
- SharePoint
|
|
14
|
+
- Excel
|
|
15
|
+
- **SAP Integration**
|
|
16
|
+
- **Solteq Tand Integration**
|
|
17
|
+
- **Utility Modules**:
|
|
18
|
+
- JSON handling
|
|
19
|
+
- Fernet encryption
|
|
20
|
+
|
|
21
|
+
## Installation
|
|
22
|
+
|
|
23
|
+
Install the package using pip:
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
pip install mbu-dev-shared-components
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
# Dynamic SQL Query Builder
|
|
30
|
+
|
|
31
|
+
This repository provides a **generic function** to dynamically build SQL `WHERE` clauses using filters. It supports:
|
|
32
|
+
|
|
33
|
+
- **Equality (`=`)**
|
|
34
|
+
- **LIKE (`%search%`)**
|
|
35
|
+
- **IN (`column IN (value1, value2, ...)`)**
|
|
36
|
+
- **BETWEEN (`column BETWEEN value1 AND value2`)**
|
|
37
|
+
- **AND & OR Conditions**
|
|
38
|
+
- **ORDER BY (`ORDER BY column ASC/DESC`)**
|
|
39
|
+
|
|
40
|
+
---
|
|
41
|
+
|
|
42
|
+
## 📌 How to Use the `check_if_event_exists` Function
|
|
43
|
+
|
|
44
|
+
| **Usage Type** | **Example Function Call** | **Generated SQL WHERE Clause** |
|
|
45
|
+
|--------------|--------------------------------------|--------------------------------------------|
|
|
46
|
+
| **1. Basic Equality Filtering** | ```python self.check_if_event_exists(filters={"p.cpr": "123456-7890", "e.event_name": "Some Clinic"}) ``` | `WHERE 1=1 AND p.cpr = ? AND e.event_name = ?` |
|
|
47
|
+
| **2. LIKE Filtering** (Partial Match) | ```python self.check_if_event_exists(filters={"e.event_name": "%Clinic%"}) ``` | `WHERE 1=1 AND e.event_name LIKE ?` |
|
|
48
|
+
| **3. IN Filtering** (Multiple Values) | ```python self.check_if_event_exists(filters={"e.event_message": ["Scheduled", "Pending"]}) ``` | `WHERE 1=1 AND e.event_message IN (?, ?)` |
|
|
49
|
+
| **4. BETWEEN Filtering** (Range) | ```python self.check_if_event_exists(filters={"e.eventTriggerDate": ("2024-01-01", "2024-12-31")}) ``` | `WHERE 1=1 AND e.eventTriggerDate BETWEEN ? AND ?` |
|
|
50
|
+
| **5. Multiple AND Conditions** | ```python self.check_if_event_exists(filters={"p.cpr": "123456-7890", "e.event_message": "Scheduled", "e.archived": 0}) ``` | `WHERE 1=1 AND p.cpr = ? AND e.event_message = ? AND e.archived = ?` |
|
|
51
|
+
| **6. OR Conditions (Single Group)** | ```python self.check_if_event_exists(or_filters=[{"e.event_name": "Clinic A"}, {"e.event_name": "Clinic B"}]) ``` | `WHERE 1=1 AND (e.event_name = ? OR e.event_name = ?)` |
|
|
52
|
+
| **7. OR with Multiple Conditions** | ```python self.check_if_event_exists(or_filters=[{"e.event_name": "Clinic A", "e.event_message": "Scheduled"}, {"e.event_name": "Clinic B"}]) ``` | `WHERE 1=1 AND ((e.event_name = ? AND e.event_message = ?) OR (e.event_name = ?))` |
|
|
53
|
+
| **8. AND & OR Combined** | ```python self.check_if_event_exists(filters={"e.archived": 0}, or_filters=[{"e.event_name": "Clinic A"}, {"e.event_name": "Clinic B"}]) ``` | `WHERE 1=1 AND e.archived = ? AND (e.event_name = ? OR e.event_name = ?)` |
|
|
54
|
+
| **9. LIKE with OR** | ```python self.check_if_event_exists(or_filters=[{"e.event_message": "%Scheduled%"}, {"e.event_message": "%Pending%"}]) ``` | `WHERE 1=1 AND (e.event_message LIKE ? OR e.event_message LIKE ?)` |
|
|
55
|
+
| **10. Complex AND, OR, LIKE, IN Combined** | ```python self.check_if_event_exists(filters={"p.cpr": "123456-7890", "e.event_message": ["Scheduled", "Pending"]}, or_filters=[{"e.event_name": "%Hospital%"}, {"e.event_name": "%Clinic%"}]) ``` | `WHERE 1=1 AND p.cpr = ? AND e.event_message IN (?, ?) AND (e.event_name LIKE ? OR e.event_name LIKE ?)` |
|
|
56
|
+
| **11. ORDER BY (Ascending)** | ```python self.check_if_event_exists(filters={"p.cpr": "123456-7890"}, order_by="e.timestamp", order_direction="ASC") ``` | `WHERE 1=1 AND p.cpr = ? ORDER BY e.timestamp ASC` |
|
|
57
|
+
| **12. ORDER BY (Descending)** | ```python self.check_if_event_exists(filters={"p.cpr": "123456-7890"}, order_by="e.timestamp", order_direction="DESC") ``` | `WHERE 1=1 AND p.cpr = ? ORDER BY e.timestamp DESC` |
|
|
58
|
+
| **13. ORDER BY with Multiple Filters** | ```python self.check_if_event_exists(filters={"e.event_message": "Scheduled"}, order_by="e.eventTriggerDate", order_direction="DESC") ``` | `WHERE 1=1 AND e.event_message = ? ORDER BY e.eventTriggerDate DESC` |
|
|
59
|
+
=======
|
|
60
|
+
```
|
|
@@ -1,131 +1,131 @@
|
|
|
1
|
-
"""This module handles generating and fetching constants and credentials from the database"""
|
|
2
|
-
|
|
3
|
-
import os
|
|
4
|
-
import pyodbc
|
|
5
|
-
from datetime import datetime
|
|
6
|
-
|
|
7
|
-
from mbu_dev_shared_components.utils.fernet_encryptor import Encryptor
|
|
8
|
-
from mbu_dev_shared_components.database.utility import connect_to_db, execute_query
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
def add_credential(
|
|
12
|
-
credential_name: str,
|
|
13
|
-
username: str,
|
|
14
|
-
password: str,
|
|
15
|
-
changed_at: datetime = datetime.now(),
|
|
16
|
-
db_env: str = "PROD"
|
|
17
|
-
):
|
|
18
|
-
encryptor = Encryptor()
|
|
19
|
-
encrypted_password = encryptor.encrypt(password)
|
|
20
|
-
|
|
21
|
-
rpa_conn = connect_to_db(db_env=db_env)
|
|
22
|
-
cursor = rpa_conn.cursor()
|
|
23
|
-
|
|
24
|
-
query = """
|
|
25
|
-
INSERT INTO [RPA].[rpa].[Credentials]
|
|
26
|
-
([name]
|
|
27
|
-
,[username]
|
|
28
|
-
,[password]
|
|
29
|
-
,[changed_at])
|
|
30
|
-
VALUES
|
|
31
|
-
(?
|
|
32
|
-
,?
|
|
33
|
-
,?
|
|
34
|
-
,?)
|
|
35
|
-
"""
|
|
36
|
-
params = [credential_name, username, encrypted_password, changed_at]
|
|
37
|
-
execute_query(query=query, cursor=cursor, params=params)
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
def get_credential(
|
|
41
|
-
credential_name: str,
|
|
42
|
-
db_env: str = "PROD"
|
|
43
|
-
) -> dict:
|
|
44
|
-
|
|
45
|
-
rpa_conn = connect_to_db(db_env=db_env)
|
|
46
|
-
cursor = rpa_conn.cursor()
|
|
47
|
-
encryptor = Encryptor()
|
|
48
|
-
|
|
49
|
-
query = """
|
|
50
|
-
SELECT
|
|
51
|
-
Username
|
|
52
|
-
,cast(Password as varbinary(max))
|
|
53
|
-
FROM [RPA].[rpa].[Credentials]
|
|
54
|
-
WHERE
|
|
55
|
-
name = ?
|
|
56
|
-
"""
|
|
57
|
-
|
|
58
|
-
params = [credential_name]
|
|
59
|
-
|
|
60
|
-
res = execute_query(query=query, cursor=cursor, params=params)
|
|
61
|
-
if res is not None:
|
|
62
|
-
res = res[0]
|
|
63
|
-
username = res[0]
|
|
64
|
-
encrypted_password = res[1]
|
|
65
|
-
|
|
66
|
-
decrypted_password = encryptor.decrypt(encrypted_password)
|
|
67
|
-
|
|
68
|
-
return {
|
|
69
|
-
"username": username,
|
|
70
|
-
"decrypted_password": decrypted_password,
|
|
71
|
-
"encrypted_password": encrypted_password
|
|
72
|
-
}
|
|
73
|
-
else:
|
|
74
|
-
print(f"No credential found with name {credential_name}")
|
|
75
|
-
|
|
76
|
-
def get_constant(
|
|
77
|
-
constant_name: str,
|
|
78
|
-
db_env: str = "PROD"
|
|
79
|
-
) -> tuple:
|
|
80
|
-
|
|
81
|
-
rpa_conn = connect_to_db(db_env=db_env)
|
|
82
|
-
cursor = rpa_conn.cursor()
|
|
83
|
-
encryptor = Encryptor()
|
|
84
|
-
|
|
85
|
-
query = """
|
|
86
|
-
SELECT
|
|
87
|
-
name
|
|
88
|
-
,value
|
|
89
|
-
FROM [RPA].[rpa].[Constants]
|
|
90
|
-
WHERE
|
|
91
|
-
name = ?
|
|
92
|
-
"""
|
|
93
|
-
|
|
94
|
-
params = [constant_name]
|
|
95
|
-
|
|
96
|
-
res = execute_query(query=query, cursor=cursor, params=params)
|
|
97
|
-
if res is not None:
|
|
98
|
-
|
|
99
|
-
returned_constant = res[0]
|
|
100
|
-
constant_name = returned_constant[0]
|
|
101
|
-
value = returned_constant[1]
|
|
102
|
-
|
|
103
|
-
return {"constant_name": constant_name, "value": value}
|
|
104
|
-
else:
|
|
105
|
-
print(f"No constant found with name: {constant_name}")
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
def add_constant(
|
|
109
|
-
constant_name: str,
|
|
110
|
-
value: str,
|
|
111
|
-
changed_at: datetime = datetime.now(),
|
|
112
|
-
db_env: str = "PROD"
|
|
113
|
-
):
|
|
114
|
-
query = """
|
|
115
|
-
INSERT INTO [RPA].[rpa].[Constants]
|
|
116
|
-
([name]
|
|
117
|
-
,[value]
|
|
118
|
-
,[changed_at])
|
|
119
|
-
VALUES
|
|
120
|
-
(?
|
|
121
|
-
,?
|
|
122
|
-
,?)
|
|
123
|
-
"""
|
|
124
|
-
|
|
125
|
-
rpa_conn = connect_to_db(db_env=db_env)
|
|
126
|
-
cursor = rpa_conn.cursor()
|
|
127
|
-
|
|
128
|
-
params = [constant_name, value, changed_at]
|
|
129
|
-
execute_query(query=query, cursor=cursor, params=params)
|
|
130
|
-
|
|
131
|
-
|
|
1
|
+
"""This module handles generating and fetching constants and credentials from the database"""
|
|
2
|
+
|
|
3
|
+
import os
|
|
4
|
+
import pyodbc
|
|
5
|
+
from datetime import datetime
|
|
6
|
+
|
|
7
|
+
from mbu_dev_shared_components.utils.fernet_encryptor import Encryptor
|
|
8
|
+
from mbu_dev_shared_components.database.utility import connect_to_db, execute_query
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
def add_credential(
|
|
12
|
+
credential_name: str,
|
|
13
|
+
username: str,
|
|
14
|
+
password: str,
|
|
15
|
+
changed_at: datetime = datetime.now(),
|
|
16
|
+
db_env: str = "PROD"
|
|
17
|
+
):
|
|
18
|
+
encryptor = Encryptor()
|
|
19
|
+
encrypted_password = encryptor.encrypt(password)
|
|
20
|
+
|
|
21
|
+
rpa_conn = connect_to_db(db_env=db_env)
|
|
22
|
+
cursor = rpa_conn.cursor()
|
|
23
|
+
|
|
24
|
+
query = """
|
|
25
|
+
INSERT INTO [RPA].[rpa].[Credentials]
|
|
26
|
+
([name]
|
|
27
|
+
,[username]
|
|
28
|
+
,[password]
|
|
29
|
+
,[changed_at])
|
|
30
|
+
VALUES
|
|
31
|
+
(?
|
|
32
|
+
,?
|
|
33
|
+
,?
|
|
34
|
+
,?)
|
|
35
|
+
"""
|
|
36
|
+
params = [credential_name, username, encrypted_password, changed_at]
|
|
37
|
+
execute_query(query=query, cursor=cursor, params=params)
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
def get_credential(
|
|
41
|
+
credential_name: str,
|
|
42
|
+
db_env: str = "PROD"
|
|
43
|
+
) -> dict:
|
|
44
|
+
|
|
45
|
+
rpa_conn = connect_to_db(db_env=db_env)
|
|
46
|
+
cursor = rpa_conn.cursor()
|
|
47
|
+
encryptor = Encryptor()
|
|
48
|
+
|
|
49
|
+
query = """
|
|
50
|
+
SELECT
|
|
51
|
+
Username
|
|
52
|
+
,cast(Password as varbinary(max))
|
|
53
|
+
FROM [RPA].[rpa].[Credentials]
|
|
54
|
+
WHERE
|
|
55
|
+
name = ?
|
|
56
|
+
"""
|
|
57
|
+
|
|
58
|
+
params = [credential_name]
|
|
59
|
+
|
|
60
|
+
res = execute_query(query=query, cursor=cursor, params=params)
|
|
61
|
+
if res is not None:
|
|
62
|
+
res = res[0]
|
|
63
|
+
username = res[0]
|
|
64
|
+
encrypted_password = res[1]
|
|
65
|
+
|
|
66
|
+
decrypted_password = encryptor.decrypt(encrypted_password)
|
|
67
|
+
|
|
68
|
+
return {
|
|
69
|
+
"username": username,
|
|
70
|
+
"decrypted_password": decrypted_password,
|
|
71
|
+
"encrypted_password": encrypted_password
|
|
72
|
+
}
|
|
73
|
+
else:
|
|
74
|
+
print(f"No credential found with name {credential_name}")
|
|
75
|
+
|
|
76
|
+
def get_constant(
|
|
77
|
+
constant_name: str,
|
|
78
|
+
db_env: str = "PROD"
|
|
79
|
+
) -> tuple:
|
|
80
|
+
|
|
81
|
+
rpa_conn = connect_to_db(db_env=db_env)
|
|
82
|
+
cursor = rpa_conn.cursor()
|
|
83
|
+
encryptor = Encryptor()
|
|
84
|
+
|
|
85
|
+
query = """
|
|
86
|
+
SELECT
|
|
87
|
+
name
|
|
88
|
+
,value
|
|
89
|
+
FROM [RPA].[rpa].[Constants]
|
|
90
|
+
WHERE
|
|
91
|
+
name = ?
|
|
92
|
+
"""
|
|
93
|
+
|
|
94
|
+
params = [constant_name]
|
|
95
|
+
|
|
96
|
+
res = execute_query(query=query, cursor=cursor, params=params)
|
|
97
|
+
if res is not None:
|
|
98
|
+
|
|
99
|
+
returned_constant = res[0]
|
|
100
|
+
constant_name = returned_constant[0]
|
|
101
|
+
value = returned_constant[1]
|
|
102
|
+
|
|
103
|
+
return {"constant_name": constant_name, "value": value}
|
|
104
|
+
else:
|
|
105
|
+
print(f"No constant found with name: {constant_name}")
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
def add_constant(
|
|
109
|
+
constant_name: str,
|
|
110
|
+
value: str,
|
|
111
|
+
changed_at: datetime = datetime.now(),
|
|
112
|
+
db_env: str = "PROD"
|
|
113
|
+
):
|
|
114
|
+
query = """
|
|
115
|
+
INSERT INTO [RPA].[rpa].[Constants]
|
|
116
|
+
([name]
|
|
117
|
+
,[value]
|
|
118
|
+
,[changed_at])
|
|
119
|
+
VALUES
|
|
120
|
+
(?
|
|
121
|
+
,?
|
|
122
|
+
,?)
|
|
123
|
+
"""
|
|
124
|
+
|
|
125
|
+
rpa_conn = connect_to_db(db_env=db_env)
|
|
126
|
+
cursor = rpa_conn.cursor()
|
|
127
|
+
|
|
128
|
+
params = [constant_name, value, changed_at]
|
|
129
|
+
execute_query(query=query, cursor=cursor, params=params)
|
|
130
|
+
|
|
131
|
+
|