DE-Lib 0.0.20__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.
Files changed (47) hide show
  1. DE_Lib/Cloud/__init__.py +0 -0
  2. DE_Lib/DataBase/Azure.py +44 -0
  3. DE_Lib/DataBase/Cache.py +74 -0
  4. DE_Lib/DataBase/Firebird.py +45 -0
  5. DE_Lib/DataBase/Informix.py +37 -0
  6. DE_Lib/DataBase/Metadata.py +62 -0
  7. DE_Lib/DataBase/MsSql.py +39 -0
  8. DE_Lib/DataBase/MySql.py +42 -0
  9. DE_Lib/DataBase/Oracle.py +111 -0
  10. DE_Lib/DataBase/Postgres.py +39 -0
  11. DE_Lib/DataBase/RedShift.py +42 -0
  12. DE_Lib/DataBase/SQCipher.py +42 -0
  13. DE_Lib/DataBase/SQLite.py +48 -0
  14. DE_Lib/DataBase/__init__.py +0 -0
  15. DE_Lib/Files/Avro.py +23 -0
  16. DE_Lib/Files/Csv.py +64 -0
  17. DE_Lib/Files/JSon.py +64 -0
  18. DE_Lib/Files/Parquet.py +31 -0
  19. DE_Lib/Files/Txt.py +64 -0
  20. DE_Lib/Files/Xlsx.py +55 -0
  21. DE_Lib/Files/__init__.py +0 -0
  22. DE_Lib/Log/DE_LogEventos.py +533 -0
  23. DE_Lib/Log/Level.py +77 -0
  24. DE_Lib/Log/Log.py +470 -0
  25. DE_Lib/Log/__init__.py +0 -0
  26. DE_Lib/Utils/Cipher/Aes.py +65 -0
  27. DE_Lib/Utils/Cipher/Argon.py +37 -0
  28. DE_Lib/Utils/Cipher/Base64.py +48 -0
  29. DE_Lib/Utils/Cipher/Cipher.py +300 -0
  30. DE_Lib/Utils/Cipher/Fernet.py +81 -0
  31. DE_Lib/Utils/Cipher/Gcm.py +78 -0
  32. DE_Lib/Utils/Cipher/Pbkdf2.py +43 -0
  33. DE_Lib/Utils/Cipher/Rsa.py +140 -0
  34. DE_Lib/Utils/Cipher/__init__.py +0 -0
  35. DE_Lib/Utils/Colors.py +203 -0
  36. DE_Lib/Utils/DateUtils.py +215 -0
  37. DE_Lib/Utils/Generic.py +249 -0
  38. DE_Lib/Utils/SQL.py +34 -0
  39. DE_Lib/Utils/System.py +50 -0
  40. DE_Lib/Utils/WebHook.py +18 -0
  41. DE_Lib/Utils/__init__.py +0 -0
  42. DE_Lib/__init__.py +0 -0
  43. de_lib-0.0.20.dist-info/LICENCE +21 -0
  44. de_lib-0.0.20.dist-info/METADATA +68 -0
  45. de_lib-0.0.20.dist-info/RECORD +47 -0
  46. de_lib-0.0.20.dist-info/WHEEL +5 -0
  47. de_lib-0.0.20.dist-info/top_level.txt +1 -0
File without changes
@@ -0,0 +1,44 @@
1
+ import redshift_connector as DB
2
+
3
+
4
+ class Azure:
5
+ def __init__(self):
6
+ self._connection_is_valid = None
7
+ self._nome_database = None
8
+ self._cnn = None
9
+ self.__database_error = None
10
+
11
+ def AZURE(self, string_connect: dict):
12
+ conn = None
13
+ try:
14
+ from azure.storage.filedatalake import DataLakeServiceClient as az
15
+
16
+ conn = az.connect(host=string_connect["host"],
17
+ database=string_connect["instance"],
18
+ user=string_connect["username"],
19
+ password=string_connect["password"]
20
+ )
21
+ self._connection_is_valid = True
22
+ self._nome_database = string_connect["database"]
23
+ except Exception as error:
24
+ self._connection_is_valid = False
25
+ self.__database_error = conn.DatabaseError
26
+ conn = error
27
+ finally:
28
+ return conn
29
+
30
+ @property
31
+ def CONNECTION(self):
32
+ return self._cnn
33
+
34
+ @property
35
+ def CONNECTION_VALID(self):
36
+ return self._connection_is_valid
37
+
38
+ @property
39
+ def NOME_DATABASE(self):
40
+ return self._nome_database.upper()
41
+
42
+ @property
43
+ def DATABASE_ERROR(self):
44
+ return self.__database_error
@@ -0,0 +1,74 @@
1
+ import jaydebeapi as jdb
2
+ import jpype as jp
3
+ import os
4
+ import json
5
+
6
+ class Cache:
7
+ def __init__(self):
8
+ self._connection_is_valid = None
9
+ self._nome_database = None
10
+ self._cnn = None
11
+ self.__database_error = None
12
+
13
+ def Connect(self, string_connect):
14
+ """
15
+ Conexao com a base CACHÉ (Intersystem)
16
+ O arquivo "CacheDB.jar" --> Tem que estar na mesma pasta de da lib ou ter o seu
17
+ caminho completo declarado na chamada da funcao
18
+ :param string_connect:
19
+ "database": "cache",
20
+ "name_conection": "Nome da conexão para melhor identicacao",
21
+ "driver": str: default = "CacheDB.jar",
22
+ "user": str: Nome do usuario,
23
+ "pwd": str: senha do usuario,
24
+ "host": str: Nome do host (Url ou IP),
25
+ "port": str: Numero da porta --> default = "1972",
26
+ "instance": str: <Nome da instanciaa ser conectada>
27
+ :return:
28
+ """
29
+ msg, result = None, None
30
+ try:
31
+ if string_connect["database"] == "":
32
+ string_connect["database"] = "cache"
33
+ if string_connect["driver_conexao"] == "":
34
+ string_connect["driver_conexao"] = "CacheDB.jar"
35
+ if string_connect["port"] == "":
36
+ string_connect["port"] = "1972"
37
+ jarODBC = os.path.join(string_connect["driver_library"], string_connect["driver_conexao"])
38
+ JHOME = jp.getDefaultJVMPath()
39
+ jp.startJVM(JHOME, f"""-Djava.class.path={jarODBC}""")
40
+ __driver = "com.intersys.jdbc.CacheDriver"
41
+ __usr = string_connect["user"]
42
+ __pwd = string_connect["pwd"]
43
+ __host = string_connect["host"]
44
+ __port = string_connect["port"]
45
+ __namespace = string_connect["instance"]
46
+ __url = f"""jdbc:Cache://{__host}:{__port}/{__namespace}"""
47
+ result = jdb.connect(__driver, __url, [__usr, __pwd])
48
+ self._connection_is_valid = True
49
+ self._cnn = result
50
+ self._database_error = f"""{json.dumps(string_connect, indent=4).replace(string_connect["pwd"], "******")}\nConexao bem sucedida!"""
51
+ self._nome_database = string_connect["database"]
52
+ except Exception as error:
53
+ msg = f"""{json.dumps(string_connect, indent=4).replace(string_connect["pwd"], "******")}\nFalha ao tentar se conectar com o banco de dados CACHÉ (intersystem)\nException Error: {error} """
54
+ result = msg
55
+ self._connection_is_valid = False
56
+ self._database_error = msg
57
+ finally:
58
+ return result
59
+
60
+ @property
61
+ def CONNECTION(self):
62
+ return self._cnn
63
+
64
+ @property
65
+ def CONNECTION_VALID(self):
66
+ return self._connection_is_valid
67
+
68
+ @property
69
+ def NOME_DATABASE(self):
70
+ return self._nome_database.upper()
71
+
72
+ @property
73
+ def DATABASE_ERROR(self):
74
+ return self._database_error
@@ -0,0 +1,45 @@
1
+ import fbd
2
+
3
+ class Firebird:
4
+ def __init__(self):
5
+ self._connection_is_valid = None
6
+ self._nome_database = None
7
+ self._cnn = None
8
+ self.__database_error = None
9
+
10
+ # ----------------------------------------------------------------
11
+ # Falta driver - maquina local não permite
12
+ def Connect(self, string_connect: dict):
13
+ msg, conn = None, None
14
+ try:
15
+ user = string_connect["username"]
16
+ pwd = string_connect["password"]
17
+ host = string_connect["host"]
18
+ port = string_connect["port"]
19
+ instance = string_connect["instance"]
20
+ conn = fbd.connect(host=host, database=instance, user=user, password=pwd, port=port)
21
+ self._connection_is_valid = True
22
+ self._nome_database = string_connect["database"]
23
+ self._cnn = conn
24
+ except Exception as error:
25
+ conn = error
26
+ self._connection_is_valid = False
27
+ self._DATABASE_ERROR = conn.DatabaseError
28
+ finally:
29
+ return conn
30
+
31
+ @property
32
+ def CONNECTION(self):
33
+ return self._cnn
34
+
35
+ @property
36
+ def CONNECTION_VALID(self):
37
+ return self._connection_is_valid
38
+
39
+ @property
40
+ def NOME_DATABASE(self):
41
+ return self._nome_database.upper()
42
+
43
+ @property
44
+ def DATABASE_ERROR(self):
45
+ return self._DATABASE_ERROR
@@ -0,0 +1,37 @@
1
+
2
+
3
+ class Informix:
4
+ def __init__(self):
5
+ self._connection_is_valid = None
6
+ self._nome_database = None
7
+ self._cnn = None
8
+ self.__database_error = None
9
+
10
+ # ----------------------------------------------------------------
11
+ # Falta tudo (Instalar driver ODBC) Maquina local não permite
12
+ def Connect(self, string_connect: dict):
13
+ try:
14
+ pass
15
+ self._connection_is_valid = True
16
+ self._cnn = None
17
+ except Exception as error:
18
+ self._connection_is_valid = False
19
+ self._DATABASE_ERROR = True
20
+ finally:
21
+ pass
22
+
23
+ @property
24
+ def CONNECTION(self):
25
+ return self._cnn
26
+
27
+ @property
28
+ def CONNECTION_VALID(self):
29
+ return self._connection_is_valid
30
+
31
+ @property
32
+ def NOME_DATABASE(self):
33
+ return self._nome_database.upper()
34
+
35
+ @property
36
+ def DATABASE_ERROR(self):
37
+ return self.__database_error
@@ -0,0 +1,62 @@
1
+ import pandas as pd
2
+
3
+ class Metadata:
4
+ def __init__(self):
5
+ ...
6
+
7
+ def getMetadados(self, table, owner: str = '', con=None, database: str = 'ORACLE', driver: str = "SQLALCHEMY"):
8
+ msg, result = None, None
9
+ try:
10
+ self._owner = owner
11
+ self._table = table
12
+ self._qry = self.QUERYS_METADADOS[database.upper()]
13
+ #cur = con.connection.cursor()
14
+ if driver.upper() == "SQLALCHEMY":
15
+ result = pd.read_sql(con=con.connection, sql=self.QUERY)
16
+ else:
17
+ result = pd.read_sql(con=con, sql=self.QUERY)
18
+ except Exception as error:
19
+ msg = error
20
+ result = msg
21
+ finally:
22
+ return result
23
+
24
+ @property
25
+ def QUERYS_METADADOS(self):
26
+ value = {
27
+ "ORACLE": f"""Select * from all_tab_columns where owner = '{self._owner}' and table_name = '{self._table}' order by column_id"""
28
+ ,
29
+ "POSTGRES": f"""Select * from information_schema.columns where table_schema = '{self._owner}' and table_name = '{self._table}' order by ordinal_position"""
30
+ , "SQLITE": f"""Select * from pragma_table_info('{self._table}') order by cid"""
31
+ ,
32
+ "MYSQL": f"""Select * from information_schema.columns where table_name = '{self._table}' order by ordinal_position"""
33
+ ,
34
+ "REDSHIFT": f"""Select column_name from information_schema.columns where table_schema ='{self._owner}' and table_name = '{self._table}' order by ordinal_position"""
35
+ ,
36
+ "CACHE": f"""SELECT * FROM INFORMATION_SCHEMA.COLUMNS where table_schema = '{self._owner}' and table_name = '{self._table}' order by ordinal_position"""
37
+ , "MSSQL": f"""select t.name Tabela
38
+ ,ac.name Coluna
39
+ ,ac.column_id
40
+ ,sep.value Comment
41
+ ,t2.name Data_Type
42
+ from sys.schemas s
43
+ join sys.tables t
44
+ on t.schema_id = s.schema_id
45
+ join sys.all_columns ac
46
+ on ac.object_id = t.object_id
47
+ join sys.types t2
48
+ on t2.system_type_id = ac.system_type_id
49
+ left join sys.extended_properties sep
50
+ on sep.major_id = t.object_id
51
+ and sep.minor_id = ac.column_id
52
+ and sep.name = 'MS_Description'
53
+ where s.name = ISNULL('{self._owner}', 'dbo')
54
+ and t.name = '{self._table}'
55
+ order by t.name, ac.column_id
56
+ """
57
+ }
58
+ return value
59
+
60
+ @property
61
+ def QUERY(self):
62
+ return self._qry
@@ -0,0 +1,39 @@
1
+ import pymssql as mssql
2
+
3
+ class MsSql:
4
+ def __init__(self):
5
+ self._connection_is_valid = None
6
+ self._nome_database = None
7
+ self._cnn = None
8
+ self.__database_error = None
9
+
10
+ def Connect(self, string_connect: dict):
11
+ msg, conn = None, None
12
+ try:
13
+ # Efetuando a conexao com a instancia do BANCO
14
+ conn = mssql.connect(user=string_connect["username"], password=string_connect["password"], database=string_connect["instance"], server=string_connect["host"])
15
+ self._connection_is_valid = True
16
+ self._nome_database = string_connect["database"]
17
+ self._cnn = conn
18
+ except Exception as error:
19
+ conn = error
20
+ self._connection_is_valid = False
21
+ self._DATABASE_ERROR = conn.DatabaseError
22
+ finally:
23
+ return conn
24
+
25
+ @property
26
+ def CONNECTION(self):
27
+ return self._cnn
28
+
29
+ @property
30
+ def CONNECTION_VALID(self):
31
+ return self._connection_is_valid
32
+
33
+ @property
34
+ def NOME_DATABASE(self):
35
+ return self._nome_database.upper()
36
+
37
+ @property
38
+ def DATABASE_ERROR(self):
39
+ return self._DATABASE_ERROR
@@ -0,0 +1,42 @@
1
+ import mysql.connector as mysql
2
+ import json
3
+
4
+ class MySql:
5
+ def __init__(self):
6
+ self._connection_is_valid = None
7
+ self._nome_database = None
8
+ self._cnn = None
9
+ self.__database_error = None
10
+
11
+ def Connect(self, string_connect: dict):
12
+ msg, conn = None, None
13
+ try:
14
+ # Efetuando a conexao com a instancia do BANCO
15
+ result = mysql.connect(user=string_connect["username"], password=string_connect["password"], database=string_connect["instance"], host=string_connect["host"])
16
+ self._connection_is_valid = True
17
+ self._cnn = result
18
+ self._DATABASE_ERROR = f"""{json.dumps(string_connect, indent=4).replace(string_connect["password"], "******")}\nConexao bem sucedida!"""
19
+ self._nome_database = string_connect["database"]
20
+ except Exception as error:
21
+ msg = f"""{json.dumps(string_connect, indent=4).replace(string_connect["password"], "******")}\nFalha ao tentar se conectar com o banco de dados MYSQL\nException Error: {error} """
22
+ result = msg
23
+ self._connection_is_valid = False
24
+ self._DATABASE_ERROR = msg
25
+ finally:
26
+ return result
27
+
28
+ @property
29
+ def CONNECTION(self):
30
+ return self._cnn
31
+
32
+ @property
33
+ def CONNECTION_VALID(self):
34
+ return self._connection_is_valid
35
+
36
+ @property
37
+ def NOME_DATABASE(self):
38
+ return self._nome_database.upper()
39
+
40
+ @property
41
+ def DATABASE_ERROR(self):
42
+ return self._DATABASE_ERROR
@@ -0,0 +1,111 @@
1
+ import os
2
+ import cx_Oracle as ora
3
+ import sqlalchemy as sqa
4
+ import json
5
+
6
+ class Oracle:
7
+ def __init__(self):
8
+ self._connection_is_valid = None
9
+ self._nome_database = None
10
+ self._cnn = None
11
+ self.__database_error = None
12
+
13
+ def Connect_ORA(self, string_connect: dict):
14
+ pathlib, msg, result = None, None, None
15
+ try:
16
+ # Definindo a Library ORACLE
17
+ if "library" in string_connect.keys():
18
+ if string_connect["library"] is None:
19
+ pathlib = os.getenv("ORACLE_LIB")
20
+ else:
21
+ pathlib = string_connect["library"]
22
+ else:
23
+ pathlib = os.getenv("ORACLE_LIB")
24
+
25
+ # Consistindo se a biblioteca do oracle ja esta iniciada
26
+ try:
27
+ ora.init_oracle_client(lib_dir=pathlib)
28
+ except:
29
+ pass
30
+ # não faz nada (e para deixar assim se nao da erro)
31
+
32
+ # Definindo o tipo de instancia SID/SERVICE_NAME
33
+ if string_connect["type_conection"].upper() == "SID":
34
+ dnsName = ora.makedsn(host=string_connect["host"], port=string_connect["port"], sid=string_connect["instance"])
35
+ else:
36
+ dnsName = ora.makedsn(host=string_connect["host"], port=string_connect["port"], service_name=string_connect["instance"])
37
+
38
+ # Efetuando a conexao com a instancia do BANCO
39
+ result = ora.connect(string_connect["username"], string_connect["password"], dnsName, threaded=True)
40
+ self._connection_is_valid = True
41
+ self._nome_database = string_connect["database"]
42
+ self._cnn = result
43
+ self.__database_error = f"""{json.dumps(string_connect, indent=4).replace(string_connect["password"], "******")}\nConexao bem sucedida!"""
44
+ except Exception as error:
45
+ msg = f"""{json.dumps(string_connect, indent=4).replace(string_connect["password"], "******")}\nFalha ao tentar se conectar com o banco de dados ORACLE\nException Error: {error} """
46
+ result = msg
47
+ self._connection_is_valid = False
48
+ self.__database_error = msg
49
+
50
+ finally:
51
+ return result
52
+
53
+ def Connect_SQLA(self, string_connect: dict):
54
+ conn = None
55
+ try:
56
+ # Definindo a Library ORACLE
57
+ if string_connect["path_library"] is None:
58
+ pathlib = os.getenv("ORACLE_LIB")
59
+ else:
60
+ pathlib = string_connect["path_library"]
61
+
62
+ # Consistindo se a biblioteca do oracle ja esta iniciada
63
+ try:
64
+ ora.init_oracle_client(lib_dir=pathlib)
65
+ except:
66
+ pass
67
+ # não faz nada (e para deixar assim se nao da erro)
68
+ # Validando se foi passado um driver para conexao
69
+ if string_connect["driver_conexao"] is None:
70
+ string_connect["driver_conexao"] = "cx_oracle"
71
+ database = string_connect["database"]
72
+ driver = string_connect["driver_conexao"]
73
+ user = string_connect["username"]
74
+ pwd = string_connect["password"]
75
+ host = string_connect["host"]
76
+ port = string_connect["port"]
77
+ string_connect["instance"] = ora.makedsn(host, port, string_connect["instance"])
78
+ # Validando o tipo de conexao (SID ou SERVICE_NAME) apenas oracle
79
+ if string_connect["type_conection"].upper() == "SERVICE_NAME":
80
+ string_connect["instance"] = string_connect["instance"].replace("SID", "SERVICE_NAME")
81
+ dnsName = string_connect["instance"]
82
+ str_cnn = f"""{database.lower()}{driver}://{user}:{pwd}@{dnsName}"""
83
+ engine = sqa.create_engine(str_cnn)
84
+ result = engine.connect()
85
+ self._connection_is_valid = True
86
+ self._cnn = result
87
+ self.__database_error = f"""{json.dumps(string_connect, indent=4).replace(string_connect["password"], "******")}\nConexao bem sucedida!"""
88
+ self._nome_database = string_connect["database"]
89
+ except Exception as error:
90
+ 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} """
91
+ result = msg
92
+ self._connection_is_valid = False
93
+ self.__database_error = msg
94
+ finally:
95
+ return result
96
+
97
+ @property
98
+ def CONNECTION(self):
99
+ return self._cnn
100
+
101
+ @property
102
+ def CONNECTION_VALID(self):
103
+ return self._connection_is_valid
104
+
105
+ @property
106
+ def NOME_DATABASE(self):
107
+ return self._nome_database.upper()
108
+
109
+ @property
110
+ def DATABASE_ERROR(self):
111
+ return self.__database_error
@@ -0,0 +1,39 @@
1
+ import psycopg2 as ps2
2
+
3
+ class Postgres:
4
+ def __init__(self):
5
+ self._connection_is_valid = None
6
+ self._nome_database = None
7
+ self._cnn = None
8
+ self.__database_error = None
9
+
10
+ def Connect(self, string_connect: dict):
11
+ msg, conn = None, None
12
+ try:
13
+ # Efetuando a conexao com a instancia do BANCO
14
+ conn = ps2.connect(user=string_connect["username"], password=string_connect["password"], database=string_connect["instance"], host=string_connect["host"])
15
+ self._connection_is_valid = True
16
+ self._nome_database = string_connect["database"]
17
+ self._cnn = conn
18
+ except Exception as error:
19
+ conn = f"""Falha ao tentar se conectar com o banco de dados POSTGRES.\n """
20
+ self._connection_is_valid = False
21
+ self._DATABASE_ERROR = conn.DatabaseError
22
+ finally:
23
+ return conn
24
+
25
+ @property
26
+ def CONNECTION(self):
27
+ return self._cnn
28
+
29
+ @property
30
+ def CONNECTION_VALID(self):
31
+ return self._connection_is_valid
32
+
33
+ @property
34
+ def NOME_DATABASE(self):
35
+ return self._nome_database.upper()
36
+
37
+ @property
38
+ def DATABASE_ERROR(self):
39
+ return self.__database_error
@@ -0,0 +1,42 @@
1
+
2
+
3
+ class RedShift:
4
+ def __init__(self):
5
+ self._connection_is_valid = None
6
+ self._nome_database = None
7
+ self._cnn = None
8
+ self.__database_error = None
9
+
10
+ def Connect(self, string_connect: dict):
11
+ conn = None
12
+ try:
13
+ conn = reds.connect(host=string_connect["host"],
14
+ database=string_connect["instance"],
15
+ user=string_connect["username"],
16
+ password=string_connect["password"]
17
+ )
18
+ self._connection_is_valid = True
19
+ self._nome_database = string_connect["database"]
20
+ self._cnn = conn
21
+ except Exception as error:
22
+ self._connection_is_valid = False
23
+ self._DATABASE_ERROR = conn.DatabaseError
24
+ conn = error
25
+ finally:
26
+ return conn
27
+
28
+ @property
29
+ def CONNECTION(self):
30
+ return self._cnn
31
+
32
+ @property
33
+ def CONNECTION_VALID(self):
34
+ return self._connection_is_valid
35
+
36
+ @property
37
+ def NOME_DATABASE(self):
38
+ return self._nome_database.upper()
39
+
40
+ @property
41
+ def DATABASE_ERROR(self):
42
+ return self._DATABASE_ERROR
@@ -0,0 +1,42 @@
1
+
2
+
3
+ class SQCipher:
4
+ def __init__(self):
5
+ self._connection_is_valid = None
6
+ self._nome_database = None
7
+ self._cnn = None
8
+ self.__database_error = None
9
+
10
+ def Connect(self, database, password):
11
+ DATABASE_NAME, result, msg, conn = None, False, None, None
12
+ try:
13
+ if os.path.isfile(database):
14
+ #conn = sqch.connect(database, password=password)
15
+ self._connection_is_valid = True
16
+ self._nome_database = 'SQLCIPHER'
17
+ self._cnn = conn
18
+ else:
19
+ msg = f"""SQLITE [{database}]- Não existe no local informado!"""
20
+ raise Exception(msg)
21
+ except Exception as error:
22
+ conn = error
23
+ self._connection_is_valid = False
24
+ self._DATABASE_ERROR = True
25
+ finally:
26
+ return conn
27
+
28
+ @property
29
+ def CONNECTION(self):
30
+ return self._cnn
31
+
32
+ @property
33
+ def CONNECTION_VALID(self):
34
+ return self._connection_is_valid
35
+
36
+ @property
37
+ def NOME_DATABASE(self):
38
+ return self._nome_database.upper()
39
+
40
+ @property
41
+ def DATABASE_ERROR(self):
42
+ return self.__database_error
@@ -0,0 +1,48 @@
1
+ import sqlite3 as sq3
2
+ import os
3
+
4
+ class SQLite:
5
+ def __init__(self):
6
+ self._connection_is_valid = None
7
+ self._nome_database = None
8
+ self._cnn = None
9
+ self.__database_error = None
10
+
11
+ def Connect(self, database, **kwargs):
12
+ result, msg, conn = False, None, None
13
+ try:
14
+ if os.path.isfile(database):
15
+ if "check_same_thread" in kwargs.keys():
16
+ __check_same_thread = kwargs.get("check_same_thread")
17
+ else:
18
+ __check_same_thread = True
19
+ result = sq3.connect(database, check_same_thread=__check_same_thread)
20
+ self._connection_is_valid = True
21
+ self._cnn = result
22
+ self.__database_error = f"""SQLITE database: {database}\nConexao bem sucedida!"""
23
+ else:
24
+ raise Exception("File NOT FOUND!")
25
+ self._nome_database = 'SQLITE'
26
+ except Exception as error:
27
+ msg = f"""SQLITE database: {database}\nFalha ao tentar se conectar com o banco de dados SQLITE\nException Error: {error} """
28
+ result = msg
29
+ self._connection_is_valid = False
30
+ self.__database_error = msg + "\n" + error
31
+ finally:
32
+ return result
33
+
34
+ @property
35
+ def CONNECTION(self):
36
+ return self._cnn
37
+
38
+ @property
39
+ def CONNECTION_VALID(self):
40
+ return self._connection_is_valid
41
+
42
+ @property
43
+ def NOME_DATABASE(self):
44
+ return self._nome_database.upper()
45
+
46
+ @property
47
+ def DATABASE_ERROR(self):
48
+ return self.__database_error
File without changes
DE_Lib/Files/Avro.py ADDED
@@ -0,0 +1,23 @@
1
+ import pandas as pd
2
+ import pandavro as pda
3
+
4
+
5
+ class AVRO:
6
+ def __init__(self):
7
+ ...
8
+
9
+ def ExportDataFrame(self,
10
+ df: pd.DataFrame,
11
+ file_name: str,
12
+ file_sufix: str = "",
13
+ file_path: str = ""
14
+ ):
15
+ msg, result = None, True
16
+ try:
17
+ pda.to_avro(file_path_or_buffer=file_name, df=df)
18
+ except Exception as error:
19
+ msg = error
20
+ result = msg
21
+ finally:
22
+ return result
23
+