maisaedu-poormans-dms 1.1.46__tar.gz → 1.1.48__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 (43) hide show
  1. {maisaedu-poormans-dms-1.1.46 → maisaedu-poormans-dms-1.1.48}/PKG-INFO +1 -1
  2. {maisaedu-poormans-dms-1.1.46 → maisaedu-poormans-dms-1.1.48}/maisaedu_poormans_dms/redshift_migration/Reader.py +8 -13
  3. {maisaedu-poormans-dms-1.1.46 → maisaedu-poormans-dms-1.1.48}/maisaedu_poormans_dms/redshift_migration/Services/AdapterSourceTarget.py +1 -25
  4. {maisaedu-poormans-dms-1.1.46 → maisaedu-poormans-dms-1.1.48}/maisaedu_poormans_dms/redshift_migration/Writer/GenericWriter.py +0 -8
  5. {maisaedu-poormans-dms-1.1.46 → maisaedu-poormans-dms-1.1.48}/maisaedu_poormans_dms/redshift_migration/Writer/WriterCDC.py +1 -1
  6. {maisaedu-poormans-dms-1.1.46 → maisaedu-poormans-dms-1.1.48}/maisaedu_poormans_dms.egg-info/PKG-INFO +1 -1
  7. {maisaedu-poormans-dms-1.1.46 → maisaedu-poormans-dms-1.1.48}/setup.py +1 -1
  8. {maisaedu-poormans-dms-1.1.46 → maisaedu-poormans-dms-1.1.48}/LICENSE +0 -0
  9. {maisaedu-poormans-dms-1.1.46 → maisaedu-poormans-dms-1.1.48}/maisaedu_poormans_dms/__init__.py +0 -0
  10. {maisaedu-poormans-dms-1.1.46 → maisaedu-poormans-dms-1.1.48}/maisaedu_poormans_dms/postgres_migration/Contracts/MigratorInterface.py +0 -0
  11. {maisaedu-poormans-dms-1.1.46 → maisaedu-poormans-dms-1.1.48}/maisaedu_poormans_dms/postgres_migration/Contracts/MigratorRowInterface.py +0 -0
  12. {maisaedu-poormans-dms-1.1.46 → maisaedu-poormans-dms-1.1.48}/maisaedu_poormans_dms/postgres_migration/Contracts/MigratorRowReaderInterface.py +0 -0
  13. {maisaedu-poormans-dms-1.1.46 → maisaedu-poormans-dms-1.1.48}/maisaedu_poormans_dms/postgres_migration/Contracts/MigratorRowWriterInterface.py +0 -0
  14. {maisaedu-poormans-dms-1.1.46 → maisaedu-poormans-dms-1.1.48}/maisaedu_poormans_dms/postgres_migration/Contracts/MigratorTableInterface.py +0 -0
  15. {maisaedu-poormans-dms-1.1.46 → maisaedu-poormans-dms-1.1.48}/maisaedu_poormans_dms/postgres_migration/Contracts/__init__.py +0 -0
  16. {maisaedu-poormans-dms-1.1.46 → maisaedu-poormans-dms-1.1.48}/maisaedu_poormans_dms/postgres_migration/Migrator.py +0 -0
  17. {maisaedu-poormans-dms-1.1.46 → maisaedu-poormans-dms-1.1.48}/maisaedu_poormans_dms/postgres_migration/MigratorRow/MigratorRow.py +0 -0
  18. {maisaedu-poormans-dms-1.1.46 → maisaedu-poormans-dms-1.1.48}/maisaedu_poormans_dms/postgres_migration/MigratorRow/Reader.py +0 -0
  19. {maisaedu-poormans-dms-1.1.46 → maisaedu-poormans-dms-1.1.48}/maisaedu_poormans_dms/postgres_migration/MigratorRow/Writer.py +0 -0
  20. {maisaedu-poormans-dms-1.1.46 → maisaedu-poormans-dms-1.1.48}/maisaedu_poormans_dms/postgres_migration/MigratorRow/__init__.py +0 -0
  21. {maisaedu-poormans-dms-1.1.46 → maisaedu-poormans-dms-1.1.48}/maisaedu_poormans_dms/postgres_migration/MigratorTable.py +0 -0
  22. {maisaedu-poormans-dms-1.1.46 → maisaedu-poormans-dms-1.1.48}/maisaedu_poormans_dms/postgres_migration/__init__.py +0 -0
  23. {maisaedu-poormans-dms-1.1.46 → maisaedu-poormans-dms-1.1.48}/maisaedu_poormans_dms/redshift_migration/Connector.py +0 -0
  24. {maisaedu-poormans-dms-1.1.46 → maisaedu-poormans-dms-1.1.48}/maisaedu_poormans_dms/redshift_migration/Contracts/WriterInterface.py +0 -0
  25. {maisaedu-poormans-dms-1.1.46 → maisaedu-poormans-dms-1.1.48}/maisaedu_poormans_dms/redshift_migration/Contracts/__init__.py +0 -0
  26. {maisaedu-poormans-dms-1.1.46 → maisaedu-poormans-dms-1.1.48}/maisaedu_poormans_dms/redshift_migration/Logger.py +0 -0
  27. {maisaedu-poormans-dms-1.1.46 → maisaedu-poormans-dms-1.1.48}/maisaedu_poormans_dms/redshift_migration/MigratorRedshift.py +0 -0
  28. {maisaedu-poormans-dms-1.1.46 → maisaedu-poormans-dms-1.1.48}/maisaedu_poormans_dms/redshift_migration/Models/ExtractionOperation.py +0 -0
  29. {maisaedu-poormans-dms-1.1.46 → maisaedu-poormans-dms-1.1.48}/maisaedu_poormans_dms/redshift_migration/Models/Struct.py +0 -0
  30. {maisaedu-poormans-dms-1.1.46 → maisaedu-poormans-dms-1.1.48}/maisaedu_poormans_dms/redshift_migration/Models/__init__.py +0 -0
  31. {maisaedu-poormans-dms-1.1.46 → maisaedu-poormans-dms-1.1.48}/maisaedu_poormans_dms/redshift_migration/Services/ExtractionOperation.py +0 -0
  32. {maisaedu-poormans-dms-1.1.46 → maisaedu-poormans-dms-1.1.48}/maisaedu_poormans_dms/redshift_migration/Services/Struct.py +0 -0
  33. {maisaedu-poormans-dms-1.1.46 → maisaedu-poormans-dms-1.1.48}/maisaedu_poormans_dms/redshift_migration/Services/__init__.py +0 -0
  34. {maisaedu-poormans-dms-1.1.46 → maisaedu-poormans-dms-1.1.48}/maisaedu_poormans_dms/redshift_migration/Types.py +0 -0
  35. {maisaedu-poormans-dms-1.1.46 → maisaedu-poormans-dms-1.1.48}/maisaedu_poormans_dms/redshift_migration/Writer/WriterNonCDC.py +0 -0
  36. {maisaedu-poormans-dms-1.1.46 → maisaedu-poormans-dms-1.1.48}/maisaedu_poormans_dms/redshift_migration/Writer/__init__.py +0 -0
  37. {maisaedu-poormans-dms-1.1.46 → maisaedu-poormans-dms-1.1.48}/maisaedu_poormans_dms/redshift_migration/__init__.py +0 -0
  38. {maisaedu-poormans-dms-1.1.46 → maisaedu-poormans-dms-1.1.48}/maisaedu_poormans_dms/sql_server_migration.py +0 -0
  39. {maisaedu-poormans-dms-1.1.46 → maisaedu-poormans-dms-1.1.48}/maisaedu_poormans_dms.egg-info/SOURCES.txt +0 -0
  40. {maisaedu-poormans-dms-1.1.46 → maisaedu-poormans-dms-1.1.48}/maisaedu_poormans_dms.egg-info/dependency_links.txt +0 -0
  41. {maisaedu-poormans-dms-1.1.46 → maisaedu-poormans-dms-1.1.48}/maisaedu_poormans_dms.egg-info/requires.txt +0 -0
  42. {maisaedu-poormans-dms-1.1.46 → maisaedu-poormans-dms-1.1.48}/maisaedu_poormans_dms.egg-info/top_level.txt +0 -0
  43. {maisaedu-poormans-dms-1.1.46 → maisaedu-poormans-dms-1.1.48}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: maisaedu-poormans-dms
3
- Version: 1.1.46
3
+ Version: 1.1.48
4
4
  Summary: A library for making database migration tasks, for +A Education
5
5
  Home-page: UNKNOWN
6
6
  Author: A+ Educação
@@ -11,7 +11,6 @@ from .Types import (
11
11
  PREFECT,
12
12
  S3,
13
13
  )
14
- from maisaedu_utilities_prefect.secrets import get_cipher_key
15
14
  from .Services.ExtractionOperation import ExtractionOperation
16
15
  from .Services.AdapterSourceTarget import AdapterSourceTarget
17
16
  from .Models.ExtractionOperation import ExtractionOperation as ExtractionOperationModel
@@ -22,19 +21,14 @@ class Reader:
22
21
  self.struct = struct
23
22
  self.s3_credentials = s3_credentials
24
23
  self.migrator_redshift_connector = migrator_redshift_connector
25
- self.__set_cipher_key()
26
-
27
- def __set_cipher_key(self):
28
- if self.migrator_redshift_connector.env == PROD:
29
- self.cipher_key = None
30
- else:
31
- self.cipher_key = get_cipher_key(self.migrator_redshift_connector.env)
32
24
 
33
25
  def get_incremental_statement(self):
34
26
  if (
35
- self.struct.source_incremental_column is not None
36
- and self.struct.target_incremental_column is not None
37
- and (self.load_option is None)
27
+ (
28
+ self.struct.source_incremental_column is not None
29
+ and self.struct.target_incremental_column is not None
30
+ and (self.load_option is None)
31
+ ) or (self.load_option == INCREMENTAL)
38
32
  ):
39
33
  sql = f"""
40
34
  select max("{self.struct.target_incremental_column}") as max_value
@@ -71,7 +65,8 @@ class Reader:
71
65
 
72
66
  return sql_return
73
67
  else:
74
- self.load_option = FULL
68
+ if (self.load_option is None):
69
+ self.load_option = FULL
75
70
  return ""
76
71
 
77
72
  def get_columns_source(self):
@@ -134,7 +129,7 @@ class Reader:
134
129
  path_file = f"raw/prefect/{self.migrator_redshift_connector.env}/{self.struct.target_schema}/{self.struct.target_table}/{time}/{idx}.parquet"
135
130
  path_file_tmp = f"raw/tmp/{self.migrator_redshift_connector.env}/{self.struct.target_schema}/{self.struct.target_table}/{time}/{idx}.csv"
136
131
 
137
- adapter = AdapterSourceTarget(self.struct, self.cipher_key)
132
+ adapter = AdapterSourceTarget(self.struct)
138
133
  chunk_df_s3 = chunk_df.copy()
139
134
 
140
135
  chunk_df_s3 = adapter.transform_data(chunk_df_s3, target_save=S3)
@@ -19,9 +19,8 @@ from ..Types import (
19
19
 
20
20
 
21
21
  class AdapterSourceTarget:
22
- def __init__(self, struct, cipher_key=None):
22
+ def __init__(self, struct):
23
23
  self.struct = struct
24
- self.cipher_key = cipher_key
25
24
 
26
25
  def convert_types(self, df):
27
26
  for c in self.struct.columns:
@@ -65,27 +64,6 @@ class AdapterSourceTarget:
65
64
 
66
65
  return df
67
66
 
68
-
69
- def __transform_sensitive_data(self, df, struct_column):
70
- if self.cipher_key is None:
71
- return df
72
- else:
73
-
74
- def cipher(x):
75
- if x is not None and x != "":
76
- last_letters = x[-3:]
77
- text = x + self.cipher_key
78
- hash_obj = hashlib.sha256()
79
- hash_obj.update(text.encode("utf-8"))
80
- result = hash_obj.hexdigest()
81
- return result + last_letters
82
-
83
- df[struct_column["source_name"]] = df[struct_column["source_name"]].apply(
84
- cipher
85
- )
86
-
87
- return df
88
-
89
67
  def transform_data(self, df, target_save=REDSHIFT):
90
68
  if target_save == REDSHIFT:
91
69
  for c in self.struct.columns:
@@ -94,8 +72,6 @@ class AdapterSourceTarget:
94
72
  else:
95
73
  if c["target_type"] == SUPER:
96
74
  df = self.__transform_super_redshift(df, c)
97
- elif c["is_sensitive_data"] is True:
98
- df = self.__transform_sensitive_data(df, c)
99
75
  elif target_save == S3:
100
76
  for c in self.struct.columns:
101
77
  if c["source_type"] == JSON or c["source_type"] == JSONB:
@@ -1,4 +1,3 @@
1
- from maisaedu_utilities_prefect.secrets import get_cipher_key
2
1
  from ..Types import PROD
3
2
 
4
3
 
@@ -8,13 +7,6 @@ class GenericWriter:
8
7
  self.struct = struct
9
8
  self.migrator_redshift_connector = migrator_redshift_connector
10
9
  self.logger = logger
11
- self.__set_cipher_key()
12
-
13
- def __set_cipher_key(self):
14
- if self.migrator_redshift_connector.env == PROD:
15
- self.cipher_key = None
16
- else:
17
- self.cipher_key = get_cipher_key(self.env)
18
10
 
19
11
  def set_temp_target_relation(self):
20
12
  self.temp_target_relation = (
@@ -15,7 +15,7 @@ class WriterCDC(GenericWriter, WriterInterface):
15
15
  def save_data_on_tmp_s3(self, bucket, df, path_file, file_name):
16
16
  def save_data_on_tmp(op, df, path_file):
17
17
  df = self.get_op_rows(df, op=op)
18
- adapter = AdapterSourceTarget(self.struct, self.cipher_key)
18
+ adapter = AdapterSourceTarget(self.struct)
19
19
  df = adapter.convert_types(df)
20
20
  df = adapter.transform_data(df)
21
21
  df = adapter.equalize_number_columns(df)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: maisaedu-poormans-dms
3
- Version: 1.1.46
3
+ Version: 1.1.48
4
4
  Summary: A library for making database migration tasks, for +A Education
5
5
  Home-page: UNKNOWN
6
6
  Author: A+ Educação
@@ -2,7 +2,7 @@ from setuptools import setup, find_packages
2
2
 
3
3
  setup(
4
4
  name="maisaedu-poormans-dms",
5
- version="1.1.46",
5
+ version="1.1.48",
6
6
  description="A library for making database migration tasks, for +A Education",
7
7
  license="MIT License",
8
8
  author="A+ Educação",