maisaedu-poormans-dms 1.1.6__tar.gz → 1.1.8__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 (42) hide show
  1. {maisaedu-poormans-dms-1.1.6 → maisaedu-poormans-dms-1.1.8}/PKG-INFO +1 -1
  2. {maisaedu-poormans-dms-1.1.6 → maisaedu-poormans-dms-1.1.8}/maisaedu_poormans_dms/redshift_migration/Models/Struct.py +4 -1
  3. {maisaedu-poormans-dms-1.1.6 → maisaedu-poormans-dms-1.1.8}/maisaedu_poormans_dms/redshift_migration/Services/AdapterSourceTarget.py +19 -12
  4. {maisaedu-poormans-dms-1.1.6 → maisaedu-poormans-dms-1.1.8}/maisaedu_poormans_dms/redshift_migration/Services/Struct.py +14 -11
  5. {maisaedu-poormans-dms-1.1.6 → maisaedu-poormans-dms-1.1.8}/maisaedu_poormans_dms/redshift_migration/Writer/WriterCDC.py +8 -4
  6. {maisaedu-poormans-dms-1.1.6 → maisaedu-poormans-dms-1.1.8}/maisaedu_poormans_dms.egg-info/PKG-INFO +1 -1
  7. {maisaedu-poormans-dms-1.1.6 → maisaedu-poormans-dms-1.1.8}/setup.py +1 -1
  8. {maisaedu-poormans-dms-1.1.6 → maisaedu-poormans-dms-1.1.8}/LICENSE +0 -0
  9. {maisaedu-poormans-dms-1.1.6 → maisaedu-poormans-dms-1.1.8}/maisaedu_poormans_dms/__init__.py +0 -0
  10. {maisaedu-poormans-dms-1.1.6 → maisaedu-poormans-dms-1.1.8}/maisaedu_poormans_dms/postgres_migration/Contracts/MigratorInterface.py +0 -0
  11. {maisaedu-poormans-dms-1.1.6 → maisaedu-poormans-dms-1.1.8}/maisaedu_poormans_dms/postgres_migration/Contracts/MigratorRowInterface.py +0 -0
  12. {maisaedu-poormans-dms-1.1.6 → maisaedu-poormans-dms-1.1.8}/maisaedu_poormans_dms/postgres_migration/Contracts/MigratorRowReaderInterface.py +0 -0
  13. {maisaedu-poormans-dms-1.1.6 → maisaedu-poormans-dms-1.1.8}/maisaedu_poormans_dms/postgres_migration/Contracts/MigratorRowWriterInterface.py +0 -0
  14. {maisaedu-poormans-dms-1.1.6 → maisaedu-poormans-dms-1.1.8}/maisaedu_poormans_dms/postgres_migration/Contracts/MigratorTableInterface.py +0 -0
  15. {maisaedu-poormans-dms-1.1.6 → maisaedu-poormans-dms-1.1.8}/maisaedu_poormans_dms/postgres_migration/Contracts/__init__.py +0 -0
  16. {maisaedu-poormans-dms-1.1.6 → maisaedu-poormans-dms-1.1.8}/maisaedu_poormans_dms/postgres_migration/Migrator.py +0 -0
  17. {maisaedu-poormans-dms-1.1.6 → maisaedu-poormans-dms-1.1.8}/maisaedu_poormans_dms/postgres_migration/MigratorRow/MigratorRow.py +0 -0
  18. {maisaedu-poormans-dms-1.1.6 → maisaedu-poormans-dms-1.1.8}/maisaedu_poormans_dms/postgres_migration/MigratorRow/Reader.py +0 -0
  19. {maisaedu-poormans-dms-1.1.6 → maisaedu-poormans-dms-1.1.8}/maisaedu_poormans_dms/postgres_migration/MigratorRow/Writer.py +0 -0
  20. {maisaedu-poormans-dms-1.1.6 → maisaedu-poormans-dms-1.1.8}/maisaedu_poormans_dms/postgres_migration/MigratorRow/__init__.py +0 -0
  21. {maisaedu-poormans-dms-1.1.6 → maisaedu-poormans-dms-1.1.8}/maisaedu_poormans_dms/postgres_migration/MigratorTable.py +0 -0
  22. {maisaedu-poormans-dms-1.1.6 → maisaedu-poormans-dms-1.1.8}/maisaedu_poormans_dms/postgres_migration/__init__.py +0 -0
  23. {maisaedu-poormans-dms-1.1.6 → maisaedu-poormans-dms-1.1.8}/maisaedu_poormans_dms/redshift_migration/Connector.py +0 -0
  24. {maisaedu-poormans-dms-1.1.6 → maisaedu-poormans-dms-1.1.8}/maisaedu_poormans_dms/redshift_migration/Contracts/WriterInterface.py +0 -0
  25. {maisaedu-poormans-dms-1.1.6 → maisaedu-poormans-dms-1.1.8}/maisaedu_poormans_dms/redshift_migration/Contracts/__init__.py +0 -0
  26. {maisaedu-poormans-dms-1.1.6 → maisaedu-poormans-dms-1.1.8}/maisaedu_poormans_dms/redshift_migration/MigratorRedshift.py +0 -0
  27. {maisaedu-poormans-dms-1.1.6 → maisaedu-poormans-dms-1.1.8}/maisaedu_poormans_dms/redshift_migration/Models/ExtractionOperation.py +0 -0
  28. {maisaedu-poormans-dms-1.1.6 → maisaedu-poormans-dms-1.1.8}/maisaedu_poormans_dms/redshift_migration/Models/__init__.py +0 -0
  29. {maisaedu-poormans-dms-1.1.6 → maisaedu-poormans-dms-1.1.8}/maisaedu_poormans_dms/redshift_migration/Reader.py +0 -0
  30. {maisaedu-poormans-dms-1.1.6 → maisaedu-poormans-dms-1.1.8}/maisaedu_poormans_dms/redshift_migration/Services/ExtractionOperation.py +0 -0
  31. {maisaedu-poormans-dms-1.1.6 → maisaedu-poormans-dms-1.1.8}/maisaedu_poormans_dms/redshift_migration/Services/__init__.py +0 -0
  32. {maisaedu-poormans-dms-1.1.6 → maisaedu-poormans-dms-1.1.8}/maisaedu_poormans_dms/redshift_migration/Types.py +0 -0
  33. {maisaedu-poormans-dms-1.1.6 → maisaedu-poormans-dms-1.1.8}/maisaedu_poormans_dms/redshift_migration/Writer/GenericWriter.py +0 -0
  34. {maisaedu-poormans-dms-1.1.6 → maisaedu-poormans-dms-1.1.8}/maisaedu_poormans_dms/redshift_migration/Writer/WriterNonCDC.py +0 -0
  35. {maisaedu-poormans-dms-1.1.6 → maisaedu-poormans-dms-1.1.8}/maisaedu_poormans_dms/redshift_migration/Writer/__init__.py +0 -0
  36. {maisaedu-poormans-dms-1.1.6 → maisaedu-poormans-dms-1.1.8}/maisaedu_poormans_dms/redshift_migration/__init__.py +0 -0
  37. {maisaedu-poormans-dms-1.1.6 → maisaedu-poormans-dms-1.1.8}/maisaedu_poormans_dms/sql_server_migration.py +0 -0
  38. {maisaedu-poormans-dms-1.1.6 → maisaedu-poormans-dms-1.1.8}/maisaedu_poormans_dms.egg-info/SOURCES.txt +0 -0
  39. {maisaedu-poormans-dms-1.1.6 → maisaedu-poormans-dms-1.1.8}/maisaedu_poormans_dms.egg-info/dependency_links.txt +0 -0
  40. {maisaedu-poormans-dms-1.1.6 → maisaedu-poormans-dms-1.1.8}/maisaedu_poormans_dms.egg-info/requires.txt +0 -0
  41. {maisaedu-poormans-dms-1.1.6 → maisaedu-poormans-dms-1.1.8}/maisaedu_poormans_dms.egg-info/top_level.txt +0 -0
  42. {maisaedu-poormans-dms-1.1.6 → maisaedu-poormans-dms-1.1.8}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: maisaedu-poormans-dms
3
- Version: 1.1.6
3
+ Version: 1.1.8
4
4
  Summary: A library for making database migration tasks, for +A Education
5
5
  Home-page: UNKNOWN
6
6
  Author: A+ Educação
@@ -29,13 +29,16 @@ class Struct:
29
29
  self.columns = []
30
30
  self.columns_upsert = []
31
31
 
32
- def add_column(self, source_name, target_name, source_type, target_type, is_upsert):
32
+ def add_column(
33
+ self, source_name, target_name, source_type, target_type, is_upsert, is_active
34
+ ):
33
35
  self.columns.append(
34
36
  {
35
37
  "source_name": source_name,
36
38
  "target_name": target_name,
37
39
  "source_type": source_type,
38
40
  "target_type": target_type,
41
+ "is_active": is_active,
39
42
  }
40
43
  )
41
44
 
@@ -58,18 +58,25 @@ class AdapterSourceTarget:
58
58
  def transform_data(self, df, target_save=REDSHIFT):
59
59
  if target_save == REDSHIFT:
60
60
  for c in self.struct.columns:
61
- if c["target_type"] == SUPER:
62
-
63
- def decode_json(x):
64
- try:
65
- return json.loads(x)
66
- except Exception as e:
67
- return {"redshift_error": "Field is too long to be saved"}
68
-
69
- df[c["source_name"]] = df[c["source_name"]].apply(json.dumps)
70
- df[c["source_name"]] = df[c["source_name"]].str[:MAX_VARCHAR_LENGTH]
71
- df[c["source_name"]] = df[c["source_name"]].apply(decode_json)
72
- df[c["source_name"]] = df[c["source_name"]].apply(json.dumps)
61
+ if c["is_active"] is False:
62
+ df[c["source_name"]] = ""
63
+ else:
64
+ if c["target_type"] == SUPER:
65
+
66
+ def decode_json(x):
67
+ try:
68
+ return json.loads(x)
69
+ except Exception as e:
70
+ return {
71
+ "redshift_error": "Field is too long to be saved"
72
+ }
73
+
74
+ df[c["source_name"]] = df[c["source_name"]].apply(json.dumps)
75
+ df[c["source_name"]] = df[c["source_name"]].str[
76
+ :MAX_VARCHAR_LENGTH
77
+ ]
78
+ df[c["source_name"]] = df[c["source_name"]].apply(decode_json)
79
+ df[c["source_name"]] = df[c["source_name"]].apply(json.dumps)
73
80
  elif target_save == S3:
74
81
  for c in self.struct.columns:
75
82
  if c["source_type"] == JSON or c["source_type"] == JSONB:
@@ -60,17 +60,19 @@ class Struct:
60
60
  )
61
61
  cursor.execute(
62
62
  f"""
63
- select
64
- source_name,
65
- target_name,
66
- source_type,
67
- target_type,
68
- is_upsert
69
- from
70
- dataeng.relations_columns_extraction
71
- where
72
- relation_id = {r[0]}
73
- and is_active is true;
63
+ select
64
+ source_name,
65
+ target_name,
66
+ source_type,
67
+ target_type,
68
+ is_upsert,
69
+ is_active
70
+ from
71
+ dataeng.relations_columns_extraction
72
+ where
73
+ relation_id = {r[0]}
74
+ order by
75
+ id;
74
76
  """
75
77
  )
76
78
  columns = cursor.fetchall()
@@ -81,6 +83,7 @@ class Struct:
81
83
  source_type=c[2],
82
84
  target_type=c[3],
83
85
  is_upsert=c[4],
86
+ is_active=c[5],
84
87
  )
85
88
 
86
89
  structs.append(struct_model)
@@ -107,9 +107,6 @@ class WriterCDC(GenericWriter, WriterInterface):
107
107
  file_content = obj.get()["Body"].read()
108
108
 
109
109
  df = pd.read_parquet(io.BytesIO(file_content))
110
- print(len(df))
111
- print("-----")
112
- print(len(main_df))
113
110
 
114
111
  main_df = pd.concat([main_df, df], ignore_index=True)
115
112
 
@@ -123,4 +120,11 @@ class WriterCDC(GenericWriter, WriterInterface):
123
120
 
124
121
  except Exception as e:
125
122
  self.delete_on_tmp_s3(bucket, path_file)
126
- raise e
123
+ raise Exception(
124
+ f"""
125
+ Error on save data on redshift
126
+ Cause of error: {e}
127
+ Operation url: {url}
128
+ You can download/check the file on s3, if the error was not direct in redshift
129
+ """
130
+ )
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: maisaedu-poormans-dms
3
- Version: 1.1.6
3
+ Version: 1.1.8
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.6",
5
+ version="1.1.8",
6
6
  description="A library for making database migration tasks, for +A Education",
7
7
  license="MIT License",
8
8
  author="A+ Educação",