python-databases 1.2.2__tar.gz → 2.1.0__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.
Files changed (22) hide show
  1. {python_databases-1.2.2/python_databases.egg-info → python_databases-2.1.0}/PKG-INFO +6 -6
  2. {python_databases-1.2.2 → python_databases-2.1.0}/pyproject.toml +8 -10
  3. {python_databases-1.2.2 → python_databases-2.1.0}/python_databases/elasticsearch_infrastructure/elasticsearch.py +14 -20
  4. {python_databases-1.2.2 → python_databases-2.1.0/python_databases.egg-info}/PKG-INFO +6 -6
  5. python_databases-2.1.0/python_databases.egg-info/requires.txt +6 -0
  6. {python_databases-1.2.2 → python_databases-2.1.0}/tests/test_elasticsearch.py +1 -1
  7. python_databases-1.2.2/python_databases.egg-info/requires.txt +0 -6
  8. {python_databases-1.2.2 → python_databases-2.1.0}/LICENSE +0 -0
  9. {python_databases-1.2.2 → python_databases-2.1.0}/MANIFEST.in +0 -0
  10. {python_databases-1.2.2 → python_databases-2.1.0}/README.md +0 -0
  11. {python_databases-1.2.2 → python_databases-2.1.0}/python_databases/__init__.py +0 -0
  12. {python_databases-1.2.2 → python_databases-2.1.0}/python_databases/consts.py +0 -0
  13. {python_databases-1.2.2 → python_databases-2.1.0}/python_databases/elasticsearch_infrastructure/__init__.py +0 -0
  14. {python_databases-1.2.2 → python_databases-2.1.0}/python_databases/elasticsearch_infrastructure/consts.py +0 -0
  15. {python_databases-1.2.2 → python_databases-2.1.0}/python_databases/postgresql_infrastructure/__init__.py +0 -0
  16. {python_databases-1.2.2 → python_databases-2.1.0}/python_databases/postgresql_infrastructure/consts.py +0 -0
  17. {python_databases-1.2.2 → python_databases-2.1.0}/python_databases/postgresql_infrastructure/postgresql.py +0 -0
  18. {python_databases-1.2.2 → python_databases-2.1.0}/python_databases.egg-info/SOURCES.txt +0 -0
  19. {python_databases-1.2.2 → python_databases-2.1.0}/python_databases.egg-info/dependency_links.txt +0 -0
  20. {python_databases-1.2.2 → python_databases-2.1.0}/python_databases.egg-info/top_level.txt +0 -0
  21. {python_databases-1.2.2 → python_databases-2.1.0}/setup.cfg +0 -0
  22. {python_databases-1.2.2 → python_databases-2.1.0}/tests/test_postgres.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: python-databases
3
- Version: 1.2.2
3
+ Version: 2.1.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,11 @@ 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.0
20
- Requires-Dist: elasticsearch<9
21
- Requires-Dist: pandas>=2.3.3
22
- Requires-Dist: psycopg2-binary>=2.9.11
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: pandas>=3.1.1
22
+ Requires-Dist: psycopg2-binary>=2.9.13
23
+ Requires-Dist: python-dotenv>=1.2.4
24
24
  Requires-Dist: retrying>=1.4.2
25
25
  Dynamic: license-file
26
26
 
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "python-databases"
7
- version = "1.2.2"
7
+ version = "2.1.0"
8
8
  description = "A Python library for managing and interacting with multiple databases seamlessly."
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.12"
@@ -21,20 +21,18 @@ classifiers = [
21
21
  ]
22
22
 
23
23
  dependencies = [
24
- "custom-python-logger>=4.0.0",
25
- "elasticsearch<9",
26
- "pandas>=2.3.3",
27
- "psycopg2-binary>=2.9.11",
28
- "python-dotenv>=1.2.1",
24
+ "custom-python-logger>=4.2.0",
25
+ "elasticsearch>=8.19.3,<9",
26
+ "pandas>=3.1.1",
27
+ "psycopg2-binary>=2.9.13",
28
+ "python-dotenv>=1.2.4",
29
29
  "retrying>=1.4.2",
30
30
  ]
31
31
 
32
32
  [dependency-groups]
33
33
  dev = [
34
- "pre-commit>=4.6.2",
35
- "pytest>=9.1.1",
36
- "setuptools>=84.0.0",
37
- "wheel>=0.48.0",
34
+ "pre-commit>=4.7.0",
35
+ "pytest>=9.2.0",
38
36
  ]
39
37
 
40
38
  [project.urls]
@@ -38,10 +38,10 @@ class ElasticSearch(ABC):
38
38
  self.password = password
39
39
 
40
40
  self.elasticsearch_port = elasticsearch_port
41
- if not self.elasticsearch_port:
42
- self.elasticsearch_url = f"{self.protocol.value}://{self.elk_hostname}"
43
- else:
41
+ if self.elasticsearch_port:
44
42
  self.elasticsearch_url = f"{self.protocol.value}://{self.elk_hostname}:{self.elasticsearch_port}"
43
+ else:
44
+ self.elasticsearch_url = f"{self.protocol.value}://{self.elk_hostname}"
45
45
  self.kibana_port = kibana_port
46
46
 
47
47
  self.elk_client = None
@@ -67,7 +67,7 @@ class ElasticSearch(ABC):
67
67
  ):
68
68
  for item in failed_response:
69
69
  if item[1]["index"]["status"] != 201 or item[1]["index"]["_shards"]["failed"] > 0:
70
- self.logger.debug(f"Failed document: \n{item}")
70
+ self.logger.error(f"Failed document: \n{item}")
71
71
  failed_response_list.append(item)
72
72
  if raise_on_error and failed_response_list:
73
73
  raise Exception(f"Failed to report {len(failed_response_list)} documents to Elasticsearch")
@@ -89,7 +89,9 @@ class ElasticSearch(ABC):
89
89
 
90
90
  if quick:
91
91
  self._set_list_of_docs_quick(
92
- list_of_docs=list_of_docs, request_timeout=request_timeout, raise_on_error=raise_on_error
92
+ list_of_docs=list_of_docs,
93
+ request_timeout=request_timeout,
94
+ raise_on_error=raise_on_error,
93
95
  )
94
96
  else:
95
97
  self._set_list_of_docs_safe(list_of_docs=list_of_docs)
@@ -97,23 +99,15 @@ class ElasticSearch(ABC):
97
99
 
98
100
  @staticmethod
99
101
  def _get_doc_with_basic_info() -> dict:
100
- doc = {}
101
-
102
102
  timestamp = datetime.now(tz=UTC)
103
103
  date_and_time_str = timestamp.isoformat()
104
- date = date_and_time_str.split("T")[0]
105
- time_part = date_and_time_str.split("T")[1].split("+")[0]
106
-
107
- doc.update(
108
- {
109
- "doc_id": timestamp.strftime("%Y%m%dT%H%M%S%f"),
110
- "timestamp": timestamp,
111
- "date_and_time_str": date_and_time_str,
112
- "date_str": date,
113
- "time_str": time_part,
114
- }
115
- )
116
- return doc
104
+ return {
105
+ "doc_id": timestamp.strftime("%Y%m%dT%H%M%S%f"),
106
+ "upload_timestamp": timestamp,
107
+ "date_and_time_str": date_and_time_str,
108
+ "date_str": date_and_time_str.split("T")[0],
109
+ "time_str": date_and_time_str.split("T")[1].split("+")[0],
110
+ }
117
111
 
118
112
  @staticmethod
119
113
  def _add_list_values_as_str(doc: dict, column: str, value: Any) -> None:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: python-databases
3
- Version: 1.2.2
3
+ Version: 2.1.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,11 @@ 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.0
20
- Requires-Dist: elasticsearch<9
21
- Requires-Dist: pandas>=2.3.3
22
- Requires-Dist: psycopg2-binary>=2.9.11
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: pandas>=3.1.1
22
+ Requires-Dist: psycopg2-binary>=2.9.13
23
+ Requires-Dist: python-dotenv>=1.2.4
24
24
  Requires-Dist: retrying>=1.4.2
25
25
  Dynamic: license-file
26
26
 
@@ -0,0 +1,6 @@
1
+ custom-python-logger>=4.2.0
2
+ elasticsearch<9,>=8.19.3
3
+ pandas>=3.1.1
4
+ psycopg2-binary>=2.9.13
5
+ python-dotenv>=1.2.4
6
+ retrying>=1.4.2
@@ -138,7 +138,7 @@ def test_doc_id_is_derived_from_the_timestamp(
138
138
  es.fill_elk_index_as_bulk(data=[{"n": 1}], doc_index_name="idx", chunk_size=100)
139
139
 
140
140
  src = _sent_docs(mock_helpers)[0]["_source"]
141
- ts = src["timestamp"]
141
+ ts = src["upload_timestamp"]
142
142
  assert isinstance(ts, datetime), f"timestamp must be a datetime, got {type(ts)}"
143
143
  assert src["doc_id"] == ts.strftime("%Y%m%dT%H%M%S%f"), "doc_id/timestamp derivation broken"
144
144
  assert src["date_and_time_str"].startswith(src["date_str"]), "date_str is not the date half"
@@ -1,6 +0,0 @@
1
- custom-python-logger>=4.0.0
2
- elasticsearch<9
3
- pandas>=2.3.3
4
- psycopg2-binary>=2.9.11
5
- python-dotenv>=1.2.1
6
- retrying>=1.4.2