python-databases 0.1.2__py3-none-any.whl → 0.1.4__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 +5 -4
- python_databases/postgresql_infrastructure/__init__.py +4 -0
- python_databases/postgresql_infrastructure/postgresql.py +4 -3
- {python_databases-0.1.2.dist-info → python_databases-0.1.4.dist-info}/METADATA +1 -1
- python_databases-0.1.4.dist-info/RECORD +10 -0
- python_databases-0.1.2.dist-info/RECORD +0 -10
- {python_databases-0.1.2.dist-info → python_databases-0.1.4.dist-info}/WHEEL +0 -0
- {python_databases-0.1.2.dist-info → python_databases-0.1.4.dist-info}/licenses/LICENSE +0 -0
- {python_databases-0.1.2.dist-info → python_databases-0.1.4.dist-info}/top_level.txt +0 -0
|
@@ -6,6 +6,7 @@ from datetime import datetime, timezone
|
|
|
6
6
|
from enum import Enum
|
|
7
7
|
from typing import Optional, Any
|
|
8
8
|
import pandas as pd
|
|
9
|
+
from custom_python_logger import get_logger
|
|
9
10
|
from elasticsearch import Elasticsearch, helpers
|
|
10
11
|
from retrying import retry
|
|
11
12
|
|
|
@@ -25,7 +26,7 @@ class ElasticSearch(ABC):
|
|
|
25
26
|
username: Optional[str],
|
|
26
27
|
password: Optional[str]
|
|
27
28
|
):
|
|
28
|
-
self.logger =
|
|
29
|
+
self.logger = get_logger(self.__class__.__name__)
|
|
29
30
|
self._change_elasticsearch_logger()
|
|
30
31
|
|
|
31
32
|
self.protocol = protocol
|
|
@@ -43,7 +44,7 @@ class ElasticSearch(ABC):
|
|
|
43
44
|
self.elk_client = None
|
|
44
45
|
|
|
45
46
|
def _change_elasticsearch_logger(self):
|
|
46
|
-
tracer =
|
|
47
|
+
tracer = get_logger('elasticsearch')
|
|
47
48
|
tracer.setLevel(logging.CRITICAL) # or desired level
|
|
48
49
|
# tracer.addHandler(logging.FileHandler('indexer.log'))
|
|
49
50
|
|
|
@@ -260,7 +261,7 @@ class ElasticSearchOnPrem(ElasticSearch):
|
|
|
260
261
|
password=password
|
|
261
262
|
)
|
|
262
263
|
|
|
263
|
-
self.logger =
|
|
264
|
+
self.logger = get_logger(self.__class__.__name__)
|
|
264
265
|
|
|
265
266
|
self.connect_to_elasticsearch()
|
|
266
267
|
|
|
@@ -303,7 +304,7 @@ class ElasticSearchCloud(ElasticSearch):
|
|
|
303
304
|
password=password
|
|
304
305
|
)
|
|
305
306
|
|
|
306
|
-
self.logger =
|
|
307
|
+
self.logger = get_logger(self.__class__.__name__)
|
|
307
308
|
|
|
308
309
|
self.connect_to_elasticsearch()
|
|
309
310
|
|
|
@@ -2,6 +2,7 @@ import logging
|
|
|
2
2
|
import os
|
|
3
3
|
from typing import Optional, Union, Any
|
|
4
4
|
import psycopg2
|
|
5
|
+
from custom_python_logger import get_logger
|
|
5
6
|
from psycopg2 import extras
|
|
6
7
|
from retrying import retry
|
|
7
8
|
|
|
@@ -15,7 +16,7 @@ class PostgreSQL:
|
|
|
15
16
|
username: Optional[str] = None,
|
|
16
17
|
password: Optional[str] = None
|
|
17
18
|
):
|
|
18
|
-
self.logger =
|
|
19
|
+
self.logger = get_logger(self.__class__.__name__)
|
|
19
20
|
|
|
20
21
|
self.name = name or os.getenv("POSTGRESQL_NAME")
|
|
21
22
|
self.host = host or os.getenv("POSTGRESQL_HOST")
|
|
@@ -42,7 +43,7 @@ class PostgreSQL:
|
|
|
42
43
|
self.create_connection()
|
|
43
44
|
return self._cursor
|
|
44
45
|
|
|
45
|
-
@retry(stop_max_attempt_number=3, wait_fixed=180000)
|
|
46
|
+
# @retry(stop_max_attempt_number=3, wait_fixed=180000)
|
|
46
47
|
def create_connection(self):
|
|
47
48
|
self.logger.info(f"Create connection to {self.host}:{self.port}")
|
|
48
49
|
|
|
@@ -53,7 +54,7 @@ class PostgreSQL:
|
|
|
53
54
|
user=self.username,
|
|
54
55
|
password=self.password,
|
|
55
56
|
)
|
|
56
|
-
self._cursor = self.
|
|
57
|
+
self._cursor = self._client.cursor(cursor_factory=extras.DictCursor)
|
|
57
58
|
|
|
58
59
|
def execute_query(self, query: str, params: Optional[Union[tuple, dict[str, Any]]] = None) -> None:
|
|
59
60
|
self.logger.debug(f"Fetch rows from DB by query {query} with params {params}")
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
python_databases/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
|
+
python_databases/elasticsearch_infrastructure/__init__.py,sha256=zLL3GJwgu5a55TgRhyl_mDbjc-qQBWOskRc0y9diqyw,296
|
|
3
|
+
python_databases/elasticsearch_infrastructure/elasticsearch.py,sha256=WWlYi7icu3mJLEFDL98XbrG2bhAyBx1u_Xv8EPEgQt8,11176
|
|
4
|
+
python_databases/postgresql_infrastructure/__init__.py,sha256=h1eJx0ogbtcF6UnN2c7uW5iCuadDab3So1VI15y3kWA,150
|
|
5
|
+
python_databases/postgresql_infrastructure/postgresql.py,sha256=zH8y5w2k2djhHLefDJhlGwa6MtoZKONhJ5vMxIxDdlc,2856
|
|
6
|
+
python_databases-0.1.4.dist-info/licenses/LICENSE,sha256=cSikHY6SZFsPZSBizCDAJ0-Bjjzxt-JtX6TVbKxwimo,1067
|
|
7
|
+
python_databases-0.1.4.dist-info/METADATA,sha256=i0_YUTvulCbHXObsil2bPLbHsXv3XDh_IxpHsx6QWrg,1792
|
|
8
|
+
python_databases-0.1.4.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
9
|
+
python_databases-0.1.4.dist-info/top_level.txt,sha256=fXcMUntaYJfKeFS7FjQ6DY4WVXYBsgdrDmhOudYs-vg,17
|
|
10
|
+
python_databases-0.1.4.dist-info/RECORD,,
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
python_databases/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
|
-
python_databases/elasticsearch_infrastructure/__init__.py,sha256=zLL3GJwgu5a55TgRhyl_mDbjc-qQBWOskRc0y9diqyw,296
|
|
3
|
-
python_databases/elasticsearch_infrastructure/elasticsearch.py,sha256=U8PVhjImk_S35KJHKEFK7Fl8cL-0A36yzLJ_KgtNTIY,11160
|
|
4
|
-
python_databases/postgresql_infrastructure/__init__.py,sha256=LG-zblOfMP6hVPKsBg0_Vu7Np90aDwZoQtZkamDOsus,46
|
|
5
|
-
python_databases/postgresql_infrastructure/postgresql.py,sha256=Hnn58f6TT2NPOyAou5EvBuH4xE6qGQfYep8wufrC_r8,2816
|
|
6
|
-
python_databases-0.1.2.dist-info/licenses/LICENSE,sha256=cSikHY6SZFsPZSBizCDAJ0-Bjjzxt-JtX6TVbKxwimo,1067
|
|
7
|
-
python_databases-0.1.2.dist-info/METADATA,sha256=wM_Kf2fxKvMk48tlW3Kx-DNnXE06-rwuQTT5hpuHSgc,1792
|
|
8
|
-
python_databases-0.1.2.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
9
|
-
python_databases-0.1.2.dist-info/top_level.txt,sha256=fXcMUntaYJfKeFS7FjQ6DY4WVXYBsgdrDmhOudYs-vg,17
|
|
10
|
-
python_databases-0.1.2.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|