DE-Lib 0.0.36__py3-none-any.whl → 0.0.36.2__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.
@@ -1,3 +1,5 @@
1
+ from logging import exception
2
+
1
3
  import pandas as pd
2
4
 
3
5
  class OracleDDL:
@@ -27,6 +29,7 @@ class OracleDDL:
27
29
  result = "DATE"
28
30
  else:
29
31
  result = "VARCHAR2(4000)"
32
+ result = "VARCHAR2(4000)"
30
33
  except Exception as error:
31
34
  msg = error
32
35
  result = msg
@@ -48,7 +51,17 @@ class OracleDDL:
48
51
  result = msg
49
52
  finally:
50
53
  return result
51
-
54
+
55
+ def truncate_table(self, table_name):
56
+ msg = result = None, None
57
+ try:
58
+ truncate_table = f"TRUNCATE TABLE {table_name}"
59
+ except Exception as error:
60
+ msg = error
61
+ result = msg
62
+ finally:
63
+ return result
64
+
52
65
  def prepare_data_for_insert(self, df):
53
66
  msg = result = None, None
54
67
  try:
@@ -62,17 +75,20 @@ class OracleDDL:
62
75
  finally:
63
76
  return result
64
77
 
65
- def create_table_and_insert_data(self, df, table_name, conn):
78
+ def create_table_and_insert_data(self, df, table_name, conn, truncate: True):
66
79
  msg = result = None, None
67
80
  try:
68
81
  cur = conn.cursor()
69
82
  try:
70
- cur.execute(f"DROP TABLE {table_name}")
71
- except:
72
- pass # Ignora se a tabela não existir
83
+ if truncate:
84
+ truncate_sql = self.truncate_table(table_name)
85
+ cur.execute(truncate_sql)
86
+ self.Table_was_truncated = truncate
73
87
 
74
- create_sql = self.generate_create_table_sql(table_name, df)
75
- cur.execute(create_sql)
88
+ create_sql = self.generate_create_table_sql(table_name, df)
89
+ cur.execute(create_sql)
90
+ except:
91
+ pass #cur.execute(f"DROP TABLE {table_name}")
76
92
 
77
93
  placeholders = ', '.join([f":{i+1}" for i in range(len(df.columns))])
78
94
  insert_sql = f"INSERT INTO {table_name} VALUES({placeholders})"
@@ -86,4 +102,12 @@ class OracleDDL:
86
102
  msg = error
87
103
  result = msg
88
104
  finally:
89
- return result
105
+ return result
106
+
107
+ @property
108
+ def Table_was_truncated(self):
109
+ return self.__Table_was_truncated
110
+
111
+ @Table_was_truncated.setter
112
+ def Table_was_truncated(self, value):
113
+ self.__Table_was_truncated = value
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: DE_Lib
3
- Version: 0.0.36
3
+ Version: 0.0.36.2
4
4
  Summary: Biblioteca de funcionalidades
5
5
  Home-page: https://github.com/DE-DATAx/DAX_DB.git
6
6
  Author: Almir J Gomes
@@ -8,7 +8,7 @@ DE_Lib/DataBase/Metadata.py,sha256=j0iJm26Sf0QvsYpN61hfwkllyW2EOA2XoFnSzEo9plE,3
8
8
  DE_Lib/DataBase/MsSql.py,sha256=tVx7fdFkw1ZNhfjqw-KuyHtT-hqJ9ZNCR2iU_ogSUVk,1640
9
9
  DE_Lib/DataBase/MySql.py,sha256=SWLJMaB30EBqaz32xwMBbc3lnemDPpF2kkkf5umlL3k,2534
10
10
  DE_Lib/DataBase/Oracle.py,sha256=n9ub6J6zNX4z62pUWjut3PGxXzLDZQ9jVhZ6eGzFPEw,9704
11
- DE_Lib/DataBase/OracleDDL.py,sha256=-GyxHOVPBkHJI3mqEura1sG__bW1JdYMFQpw-2HEzWE,3046
11
+ DE_Lib/DataBase/OracleDDL.py,sha256=stvpVcQwOpZUmQXrQTH1IN3keYj_tQFjzKcKDil2_C0,3793
12
12
  DE_Lib/DataBase/Postgres.py,sha256=lMb6sFGvjjuuq4D4k7zzEo7-NtyrC79VITeKQfoDO6U,1667
13
13
  DE_Lib/DataBase/RedShift.py,sha256=ewPi8hxEhfuekBpMl-P1LWgSGfbqPKRpXfjtduCwOKc,1736
14
14
  DE_Lib/DataBase/SQCipher.py,sha256=Bw7nq4tQdhM7ux0INF9PUymsIIjBEwMKcA1Un8orCE8,1625
@@ -42,8 +42,8 @@ DE_Lib/Utils/Cipher/Gcm.py,sha256=fOuCVOyd4sGv389E91yqomujKTtFZu6CyhySrmQKVfY,23
42
42
  DE_Lib/Utils/Cipher/Pbkdf2.py,sha256=hRkgf0Fo5hV1gLbWlFGFzhYYUjPEqgpB2R-pPw7N2F8,1210
43
43
  DE_Lib/Utils/Cipher/Rsa.py,sha256=MYG1YsGuq-Q-MoF6pmeMD0TyxMTwt6tuUaLvXcmzQ2k,4126
44
44
  DE_Lib/Utils/Cipher/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
45
- de_lib-0.0.36.dist-info/licenses/LICENCE,sha256=Qv2ilebwoUtMJnRsZwRy729xS5JZQzLauJ0tQzkAkTA,1088
46
- de_lib-0.0.36.dist-info/METADATA,sha256=vkfoyshVo506OImbauRZ8ugi83zZwdoIpm3wOBZf-SA,2287
47
- de_lib-0.0.36.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
48
- de_lib-0.0.36.dist-info/top_level.txt,sha256=yI9fdM_jkhCz_sykPZQbfeUbQ1FRMt-xjv9fJ6YZVLE,7
49
- de_lib-0.0.36.dist-info/RECORD,,
45
+ de_lib-0.0.36.2.dist-info/licenses/LICENCE,sha256=Qv2ilebwoUtMJnRsZwRy729xS5JZQzLauJ0tQzkAkTA,1088
46
+ de_lib-0.0.36.2.dist-info/METADATA,sha256=gjvzXNpsiqzVsh_8NWb6kyUcbuRpVTin26-Npw2m82g,2289
47
+ de_lib-0.0.36.2.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
48
+ de_lib-0.0.36.2.dist-info/top_level.txt,sha256=yI9fdM_jkhCz_sykPZQbfeUbQ1FRMt-xjv9fJ6YZVLE,7
49
+ de_lib-0.0.36.2.dist-info/RECORD,,