python-databases 2.0.0__py3-none-any.whl → 2.2.0__py3-none-any.whl
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.
- python_databases/elasticsearch_infrastructure/elasticsearch.py +14 -34
- {python_databases-2.0.0.dist-info → python_databases-2.2.0.dist-info}/METADATA +5 -6
- {python_databases-2.0.0.dist-info → python_databases-2.2.0.dist-info}/RECORD +6 -6
- {python_databases-2.0.0.dist-info → python_databases-2.2.0.dist-info}/WHEEL +1 -1
- {python_databases-2.0.0.dist-info → python_databases-2.2.0.dist-info}/licenses/LICENSE +0 -0
- {python_databases-2.0.0.dist-info → python_databases-2.2.0.dist-info}/top_level.txt +0 -0
|
@@ -6,7 +6,6 @@ from datetime import UTC, datetime
|
|
|
6
6
|
from enum import Enum
|
|
7
7
|
from typing import Any
|
|
8
8
|
|
|
9
|
-
import pandas as pd
|
|
10
9
|
from custom_python_logger import get_logger
|
|
11
10
|
from elasticsearch import Elasticsearch, helpers
|
|
12
11
|
from retrying import retry
|
|
@@ -38,10 +37,10 @@ class ElasticSearch(ABC):
|
|
|
38
37
|
self.password = password
|
|
39
38
|
|
|
40
39
|
self.elasticsearch_port = elasticsearch_port
|
|
41
|
-
if
|
|
42
|
-
self.elasticsearch_url = f"{self.protocol.value}://{self.elk_hostname}"
|
|
43
|
-
else:
|
|
40
|
+
if self.elasticsearch_port:
|
|
44
41
|
self.elasticsearch_url = f"{self.protocol.value}://{self.elk_hostname}:{self.elasticsearch_port}"
|
|
42
|
+
else:
|
|
43
|
+
self.elasticsearch_url = f"{self.protocol.value}://{self.elk_hostname}"
|
|
45
44
|
self.kibana_port = kibana_port
|
|
46
45
|
|
|
47
46
|
self.elk_client = None
|
|
@@ -67,7 +66,7 @@ class ElasticSearch(ABC):
|
|
|
67
66
|
):
|
|
68
67
|
for item in failed_response:
|
|
69
68
|
if item[1]["index"]["status"] != 201 or item[1]["index"]["_shards"]["failed"] > 0:
|
|
70
|
-
self.logger.
|
|
69
|
+
self.logger.error(f"Failed document: \n{item}")
|
|
71
70
|
failed_response_list.append(item)
|
|
72
71
|
if raise_on_error and failed_response_list:
|
|
73
72
|
raise Exception(f"Failed to report {len(failed_response_list)} documents to Elasticsearch")
|
|
@@ -89,7 +88,9 @@ class ElasticSearch(ABC):
|
|
|
89
88
|
|
|
90
89
|
if quick:
|
|
91
90
|
self._set_list_of_docs_quick(
|
|
92
|
-
list_of_docs=list_of_docs,
|
|
91
|
+
list_of_docs=list_of_docs,
|
|
92
|
+
request_timeout=request_timeout,
|
|
93
|
+
raise_on_error=raise_on_error,
|
|
93
94
|
)
|
|
94
95
|
else:
|
|
95
96
|
self._set_list_of_docs_safe(list_of_docs=list_of_docs)
|
|
@@ -97,23 +98,15 @@ class ElasticSearch(ABC):
|
|
|
97
98
|
|
|
98
99
|
@staticmethod
|
|
99
100
|
def _get_doc_with_basic_info() -> dict:
|
|
100
|
-
doc = {}
|
|
101
|
-
|
|
102
101
|
timestamp = datetime.now(tz=UTC)
|
|
103
102
|
date_and_time_str = timestamp.isoformat()
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
"date_and_time_str": date_and_time_str,
|
|
112
|
-
"date_str": date,
|
|
113
|
-
"time_str": time_part,
|
|
114
|
-
}
|
|
115
|
-
)
|
|
116
|
-
return doc
|
|
103
|
+
return {
|
|
104
|
+
"doc_id": timestamp.strftime("%Y%m%dT%H%M%S%f"),
|
|
105
|
+
"upload_timestamp": timestamp,
|
|
106
|
+
"date_and_time_str": date_and_time_str,
|
|
107
|
+
"date_str": date_and_time_str.split("T")[0],
|
|
108
|
+
"time_str": date_and_time_str.split("T")[1].split("+")[0],
|
|
109
|
+
}
|
|
117
110
|
|
|
118
111
|
@staticmethod
|
|
119
112
|
def _add_list_values_as_str(doc: dict, column: str, value: Any) -> None:
|
|
@@ -218,19 +211,6 @@ class ElasticSearch(ABC):
|
|
|
218
211
|
except Exception as e:
|
|
219
212
|
raise Exception(f"Failed to get documents from index '{index}': {str(e)}") from e
|
|
220
213
|
|
|
221
|
-
def convert_dataframes_to_list_of_docs(
|
|
222
|
-
self,
|
|
223
|
-
dataframe: pd.DataFrame,
|
|
224
|
-
log_progress: bool = False,
|
|
225
|
-
) -> list:
|
|
226
|
-
data = []
|
|
227
|
-
dataframe_values = dataframe.values.tolist()
|
|
228
|
-
for index, value in enumerate(dataframe_values):
|
|
229
|
-
if log_progress:
|
|
230
|
-
self.logger.debug(f"index: {index}/{len(dataframe_values)}")
|
|
231
|
-
data.append(value)
|
|
232
|
-
return data
|
|
233
|
-
|
|
234
214
|
|
|
235
215
|
class ElasticSearchOnPrem(ElasticSearch):
|
|
236
216
|
def __init__(
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: python-databases
|
|
3
|
-
Version: 2.
|
|
3
|
+
Version: 2.2.0
|
|
4
4
|
Summary: A Python library for managing and interacting with multiple databases seamlessly.
|
|
5
5
|
Author: Avi Zaguri
|
|
6
6
|
License: MIT
|
|
@@ -16,11 +16,10 @@ Classifier: Topic :: System :: Logging
|
|
|
16
16
|
Requires-Python: >=3.12
|
|
17
17
|
Description-Content-Type: text/markdown
|
|
18
18
|
License-File: LICENSE
|
|
19
|
-
Requires-Dist: custom-python-logger>=4.0
|
|
20
|
-
Requires-Dist: elasticsearch<9
|
|
21
|
-
Requires-Dist:
|
|
22
|
-
Requires-Dist:
|
|
23
|
-
Requires-Dist: python-dotenv>=1.2.1
|
|
19
|
+
Requires-Dist: custom-python-logger>=4.2.0
|
|
20
|
+
Requires-Dist: elasticsearch<9,>=8.19.3
|
|
21
|
+
Requires-Dist: psycopg2-binary>=2.9.13
|
|
22
|
+
Requires-Dist: python-dotenv>=1.2.4
|
|
24
23
|
Requires-Dist: retrying>=1.4.2
|
|
25
24
|
Dynamic: license-file
|
|
26
25
|
|
|
@@ -2,12 +2,12 @@ python_databases/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,
|
|
|
2
2
|
python_databases/consts.py,sha256=ADn3PmhTXKBobtiVgDR4Tqq2Ncn_FTK0WjgREOLdBPs,33
|
|
3
3
|
python_databases/elasticsearch_infrastructure/__init__.py,sha256=U1orkPi0Pg-1rtY1CPSF4-eVRfrMr36qpT9VNKjBUw4,297
|
|
4
4
|
python_databases/elasticsearch_infrastructure/consts.py,sha256=MBZL90yjYUmipayzj65-XEBS-4qTRhClGatnEwy7OfA,98
|
|
5
|
-
python_databases/elasticsearch_infrastructure/elasticsearch.py,sha256=
|
|
5
|
+
python_databases/elasticsearch_infrastructure/elasticsearch.py,sha256=qApNFrB5U2NlEcHHE-ePiAWBckiG0cD2IA9bMYcvx-s,10513
|
|
6
6
|
python_databases/postgresql_infrastructure/__init__.py,sha256=yBjq7SLnNgnxW0DCQHEwCi_FrCNtjsJGJXIq7XtkUZg,150
|
|
7
7
|
python_databases/postgresql_infrastructure/consts.py,sha256=1GPwiyRMyQJOgdz2np0H12cr9GrP9p3aR6APCli2Hs8,102
|
|
8
8
|
python_databases/postgresql_infrastructure/postgresql.py,sha256=tFdQr5IOPYbuqKE3r9oqSoNoGMbED5NSEy1anrUNEyY,3105
|
|
9
|
-
python_databases-2.
|
|
10
|
-
python_databases-2.
|
|
11
|
-
python_databases-2.
|
|
12
|
-
python_databases-2.
|
|
13
|
-
python_databases-2.
|
|
9
|
+
python_databases-2.2.0.dist-info/licenses/LICENSE,sha256=cSikHY6SZFsPZSBizCDAJ0-Bjjzxt-JtX6TVbKxwimo,1067
|
|
10
|
+
python_databases-2.2.0.dist-info/METADATA,sha256=ZuO-_JRrq1qMpW6VT8G0ll2AFm026IVkDUEu8Wf6L94,2318
|
|
11
|
+
python_databases-2.2.0.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
|
|
12
|
+
python_databases-2.2.0.dist-info/top_level.txt,sha256=fXcMUntaYJfKeFS7FjQ6DY4WVXYBsgdrDmhOudYs-vg,17
|
|
13
|
+
python_databases-2.2.0.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|