mgcomtools 0.1.2__tar.gz → 0.1.4__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.
- {mgcomtools-0.1.2 → mgcomtools-0.1.4}/PKG-INFO +1 -1
- {mgcomtools-0.1.2 → mgcomtools-0.1.4}/mgcomtools/postgres.py +5 -4
- {mgcomtools-0.1.2 → mgcomtools-0.1.4}/mgcomtools/schema.py +4 -5
- {mgcomtools-0.1.2 → mgcomtools-0.1.4}/mgcomtools.egg-info/PKG-INFO +1 -1
- {mgcomtools-0.1.2 → mgcomtools-0.1.4}/setup.py +1 -1
- {mgcomtools-0.1.2 → mgcomtools-0.1.4}/mgcomtools/__init__.py +0 -0
- {mgcomtools-0.1.2 → mgcomtools-0.1.4}/mgcomtools/gcp.py +0 -0
- {mgcomtools-0.1.2 → mgcomtools-0.1.4}/mgcomtools/tables.py +0 -0
- {mgcomtools-0.1.2 → mgcomtools-0.1.4}/mgcomtools/telegram.py +0 -0
- {mgcomtools-0.1.2 → mgcomtools-0.1.4}/mgcomtools/test.py +0 -0
- {mgcomtools-0.1.2 → mgcomtools-0.1.4}/mgcomtools.egg-info/SOURCES.txt +0 -0
- {mgcomtools-0.1.2 → mgcomtools-0.1.4}/mgcomtools.egg-info/dependency_links.txt +0 -0
- {mgcomtools-0.1.2 → mgcomtools-0.1.4}/mgcomtools.egg-info/top_level.txt +0 -0
- {mgcomtools-0.1.2 → mgcomtools-0.1.4}/setup.cfg +0 -0
|
@@ -27,7 +27,8 @@ def connect_with_connector() -> sqlalchemy.engine.base.Engine:
|
|
|
27
27
|
db_pass = 's7<f?exPFix65SUD'
|
|
28
28
|
db_name = 'test_db'
|
|
29
29
|
|
|
30
|
-
|
|
30
|
+
os.environ["PRIVATE_IP"] = "10.77.125.3"
|
|
31
|
+
ip_type = IPTypes.PRIVATE if os.environ.get("PRIVATE_IP") else IPTypes.PUBLIC
|
|
31
32
|
|
|
32
33
|
# initialize Cloud SQL Python Connector object
|
|
33
34
|
connector = Connector()
|
|
@@ -62,13 +63,13 @@ def fetch(executed):
|
|
|
62
63
|
return [dict(row) for row in executed.fetchall()]
|
|
63
64
|
|
|
64
65
|
# данные для трансформации из таблицы BQ
|
|
65
|
-
def get_logs_to_transform(previous, step):
|
|
66
|
+
def get_logs_to_transform(previous, step, condition=''):
|
|
66
67
|
|
|
67
68
|
#Получаем данные для обработки
|
|
68
69
|
query = f"""
|
|
69
70
|
SELECT ftp, log_type, log_date, path, MAX(ftp_upload_time)
|
|
70
71
|
FROM "adriver-logs"
|
|
71
|
-
WHERE {previous} = TRUE AND {step} is NULL
|
|
72
|
+
WHERE {previous} = TRUE AND {step} is NULL {condition}
|
|
72
73
|
GROUP BY ftp, log_type, log_date, path
|
|
73
74
|
"""
|
|
74
75
|
|
|
@@ -80,7 +81,7 @@ def update_meta_data(path, step, status, bool='TRUE', option=''):
|
|
|
80
81
|
query = f"""
|
|
81
82
|
UPDATE "adriver-logs"
|
|
82
83
|
SET status = '{status}', {step} = {bool}
|
|
83
|
-
WHERE path = '{path}' AND {step} is NULL{option};
|
|
84
|
+
WHERE path = '{path}' AND {step} is NULL {option};
|
|
84
85
|
"""
|
|
85
86
|
|
|
86
87
|
conn.execute(query)
|
|
@@ -11,7 +11,6 @@ class UpdateSchema:
|
|
|
11
11
|
|
|
12
12
|
def __init__(self, df, path):
|
|
13
13
|
self.path = path
|
|
14
|
-
print(path)
|
|
15
14
|
self.df = df
|
|
16
15
|
|
|
17
16
|
|
|
@@ -20,8 +19,8 @@ class UpdateSchema:
|
|
|
20
19
|
UpdateSchema._query_already_got[self.path] = self.get_schema_from_bq()
|
|
21
20
|
self.schema = UpdateSchema._query_already_got[self.path]
|
|
22
21
|
self.transform()
|
|
23
|
-
print(UpdateSchema._query_already_got)
|
|
24
|
-
print('Schema has been updated succesfully')
|
|
22
|
+
# print(UpdateSchema._query_already_got)
|
|
23
|
+
# print('Schema has been updated succesfully')
|
|
25
24
|
|
|
26
25
|
return self.df
|
|
27
26
|
|
|
@@ -34,7 +33,7 @@ class UpdateSchema:
|
|
|
34
33
|
"""
|
|
35
34
|
query_job = bq_client.query(query).result()
|
|
36
35
|
schema_dict = dict()
|
|
37
|
-
print(query)
|
|
36
|
+
# print(query)
|
|
38
37
|
|
|
39
38
|
for row in query_job:
|
|
40
39
|
column_name = row['field_name']
|
|
@@ -84,7 +83,7 @@ class PySparkDataFrame(UpdateSchema):
|
|
|
84
83
|
def transform(data, path):
|
|
85
84
|
|
|
86
85
|
if isinstance(data, pd.DataFrame):
|
|
87
|
-
print("Это pandas DataFrame")
|
|
86
|
+
# print("Это pandas DataFrame")
|
|
88
87
|
df_obj = PandasDataFrame(data, path)
|
|
89
88
|
|
|
90
89
|
# Проверка типа для PySpark DataFrame
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|