DE-Lib 0.0.40__py3-none-any.whl → 0.0.42__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.
DE_Lib/DataBase/MsSql.py CHANGED
@@ -1,4 +1,5 @@
1
1
  import pymssql as mssql
2
+ import json
2
3
 
3
4
  from DE_Lib.Utils import Generic
4
5
 
@@ -12,7 +13,7 @@ class MSSQL:
12
13
  self.__database_error = None
13
14
 
14
15
  def Connect(self, string_connect: dict):
15
- msg, conn = None, None
16
+ msg, conn, result = None, None, None
16
17
  try:
17
18
  # Efetuando a conexao com a instancia do BANCO
18
19
  conn = mssql.connect(user=string_connect["username"], password=string_connect["password"], database=string_connect["instance"], server=string_connect["host"])
@@ -42,4 +43,4 @@ class MSSQL:
42
43
 
43
44
  @property
44
45
  def DATABASE_ERROR(self):
45
- return self._DATABASE_ERROR
46
+ return self.__database_error
DE_Lib/DataBase/Oracle.py CHANGED
@@ -2,6 +2,7 @@ import os
2
2
  import cx_Oracle as ora
3
3
  import oracledb as odb
4
4
  import sqlalchemy as sqa
5
+ from sqlalchemy import create_engine, text
5
6
  import json
6
7
 
7
8
  from DE_Lib.Utils import Generic
@@ -71,7 +72,8 @@ class ORACLE:
71
72
  __driver = conn["driver_library"].lower()
72
73
  conn_cnn = f"""{conn["database"].lower()}+{__driver}://{conn["username"]}:{conn["password"]}@{__dnsName}"""
73
74
  __engine = sqa.create_engine(conn_cnn)
74
- __conn = __engine.connect().connection
75
+ with __engine.connect() as connection:
76
+ __conn = connection.execute(text("select 1 from dual"))
75
77
  elif conn["driver_conexao"].upper() == "CX_ORACLE":
76
78
  __conn = ora.connect(conn["username"], conn["password"], __dnsName, threaded=True)
77
79
  elif conn["driver_conexao"].upper() == "ORACLEDB" or conn is None:
@@ -88,9 +90,12 @@ class ORACLE:
88
90
  #endregion
89
91
  except Exception as error:
90
92
  msg = f"""{json.dumps(conn, indent=4).replace(conn["password"], "******")}\nFalha ao tentar se conectar com o banco de dados ORACLE (SqlAlchemy)\nException Error: {error} """
91
- self._connection_is_valid = False
93
+ self.__cnn = msg
94
+ self.__connection_is_valid = False
92
95
  self.__database_error = msg
96
+ self.__database_driver = conn["driver_conexao"]
93
97
  result = self._connection_is_valid
98
+ self.__nome_database = gen.nvl(conn["database"], "")
94
99
  finally:
95
100
  return result
96
101
 
@@ -166,16 +171,20 @@ class ORACLE:
166
171
  dnsName = string_connect["instance"]
167
172
  str_cnn = f"""{database.lower()}{driver}://{user}:{pwd}@{dnsName}"""
168
173
  engine = sqa.create_engine(str_cnn)
169
- result = engine.connect()
170
- self._connection_is_valid = True
171
- self._cnn = result
172
- self.__database_error = f"""{json.dumps(string_connect, indent=4).replace(string_connect["password"], "******")}\nConexao bem sucedida!"""
173
- self._nome_database = gen.nvl(string_connect["database"], "")
174
+ with engine.connect() as connection:
175
+ result = connection.execute(text("Select 1 from dual"))
176
+ #result = engine.connect()
177
+ self._connection_is_valid = True
178
+ self._cnn = result
179
+ self.__database_error = f"""{json.dumps(string_connect, indent=4).replace(string_connect["password"], "******")}\nConexao bem sucedida!"""
180
+ self._nome_database = gen.nvl(string_connect["database"], "")
174
181
  except Exception as error:
175
182
  msg = f"""{json.dumps(string_connect, indent=4).replace(string_connect["password"], "******")}\nFalha ao tentar se conectar com o banco de dados ORACLE (SqlAlchemy)\nException Error: {error} """
176
- result = msg
177
183
  self._connection_is_valid = False
178
184
  self.__database_error = msg
185
+ self._cnn = False
186
+ self._nome_database = gen.nvl(string_connect["database"], "")
187
+ result = self._cnn
179
188
  finally:
180
189
  return result
181
190
  #endregion
DE_Lib/DataBase/SQLite.py CHANGED
@@ -18,6 +18,7 @@ class SQLITE:
18
18
  msg, result = None, True
19
19
  try:
20
20
  __file = os.path.join(conn["host"], conn["instance"])
21
+ __con = ""
21
22
  if os.path.isfile(__file):
22
23
  if "check_same_thread" in kwargs.keys():
23
24
  __check_same_thread = kwargs.get("check_same_thread")
@@ -31,7 +32,7 @@ class SQLITE:
31
32
  engine = sqa.create_engine(f"""sqlite:///{__file}""")
32
33
  __conn = engine.connect()
33
34
  else:
34
- ...
35
+ __conn = ""
35
36
  # driver nativo sqlite
36
37
 
37
38
  self._connection_is_valid = True
@@ -39,11 +40,14 @@ class SQLITE:
39
40
  self._nome_database = gen.nvl(conn["database"], "SQLite")
40
41
  self.__database_driver = conn["driver_conexao"]
41
42
  self.__database_error = result
43
+ result= self._cnn
42
44
  except Exception as error:
43
45
  msg = f"""{json.dumps(conn, indent=4).replace(conn["password"], "******")}\nFalha ao tentar se conectar com o banco de dados SQLite\nException Error: {error} """
44
46
  result = msg
45
47
  self._connection_is_valid = False
46
48
  self.__database_error = msg
49
+ self._nome_database = gen.nvl(conn["database"], "SQLite")
50
+ self.__database_driver = conn["driver_conexao"]
47
51
  finally:
48
52
  return result
49
53
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: DE_Lib
3
- Version: 0.0.40
3
+ Version: 0.0.42
4
4
  Summary: Biblioteca de funcionalidades
5
5
  Home-page: https://github.com/DE-DataEng/DE_Lib.git
6
6
  Author: Almir J Gomes
@@ -5,14 +5,14 @@ DE_Lib/DataBase/Cache.py,sha256=IpTJCVCrtm8Et4U-_AaWoT_2vf7mBqdzYrWDXbpOORE,3171
5
5
  DE_Lib/DataBase/Firebird.py,sha256=dXjt3ImVtdiW99NAHcDIzZhGHF_YIyn4RJbM2QR4g7s,1898
6
6
  DE_Lib/DataBase/Informix.py,sha256=jXqPggYu8PjGrqtxMHwlCsqF5rK03olas5yVMH0Ndkw,1559
7
7
  DE_Lib/DataBase/Metadata.py,sha256=j0iJm26Sf0QvsYpN61hfwkllyW2EOA2XoFnSzEo9plE,3274
8
- DE_Lib/DataBase/MsSql.py,sha256=tVx7fdFkw1ZNhfjqw-KuyHtT-hqJ9ZNCR2iU_ogSUVk,1640
8
+ DE_Lib/DataBase/MsSql.py,sha256=eszkLLtRwhZq0IPkApiBTjYqcs1hqwPizC8wfpC6Vrk,1668
9
9
  DE_Lib/DataBase/MySql.py,sha256=SWLJMaB30EBqaz32xwMBbc3lnemDPpF2kkkf5umlL3k,2534
10
- DE_Lib/DataBase/Oracle.py,sha256=n9ub6J6zNX4z62pUWjut3PGxXzLDZQ9jVhZ6eGzFPEw,9704
10
+ DE_Lib/DataBase/Oracle.py,sha256=EHZckkiMXZyQvMHAoPg-IoupSW4GvjOJsxnu-xRr3_Q,10239
11
11
  DE_Lib/DataBase/OracleDDL.py,sha256=8PDTjR52Igtj-FyPQvFUBRjTlXB7crMNB8Xh5LncB_Q,3785
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
15
- DE_Lib/DataBase/SQLite.py,sha256=_KScVOmF-dZGQDGVYTUkmXJdsJJDzR8VORH50HBaCLA,2342
15
+ DE_Lib/DataBase/SQLite.py,sha256=RBPcdi-0rKNQsznNv93jwseZKwFD3x5Hhk15-bYG53E,2537
16
16
  DE_Lib/DataBase/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
17
17
  DE_Lib/Files/Avro.py,sha256=hVXwoOSESHzWROBNYSDOu4myIrcRqSiPqGLRA40vJAk,527
18
18
  DE_Lib/Files/Csv.py,sha256=8mpD2g4Ej2RHQvxMODEpBDbxMV5pWJ8dJHyO8YZchuk,2430
@@ -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.40.dist-info/licenses/LICENCE,sha256=Qv2ilebwoUtMJnRsZwRy729xS5JZQzLauJ0tQzkAkTA,1088
46
- de_lib-0.0.40.dist-info/METADATA,sha256=Du9jlp1HLLybgRkVMeLJu9VhpfqGt08VgTvlnMYbkR8,2315
47
- de_lib-0.0.40.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
48
- de_lib-0.0.40.dist-info/top_level.txt,sha256=yI9fdM_jkhCz_sykPZQbfeUbQ1FRMt-xjv9fJ6YZVLE,7
49
- de_lib-0.0.40.dist-info/RECORD,,
45
+ de_lib-0.0.42.dist-info/licenses/LICENCE,sha256=Qv2ilebwoUtMJnRsZwRy729xS5JZQzLauJ0tQzkAkTA,1088
46
+ de_lib-0.0.42.dist-info/METADATA,sha256=DtJG-E84BooMce_631pF03EKJ-k2dO4b67_HmBacz6E,2315
47
+ de_lib-0.0.42.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
48
+ de_lib-0.0.42.dist-info/top_level.txt,sha256=yI9fdM_jkhCz_sykPZQbfeUbQ1FRMt-xjv9fJ6YZVLE,7
49
+ de_lib-0.0.42.dist-info/RECORD,,