lbxtoolkit 2.3.0__tar.gz → 2.3.1__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.
- {lbxtoolkit-2.3.0 → lbxtoolkit-2.3.1}/PKG-INFO +1 -1
- {lbxtoolkit-2.3.0 → lbxtoolkit-2.3.1}/lbxtoolkit/postgresql.py +12 -3
- {lbxtoolkit-2.3.0 → lbxtoolkit-2.3.1}/pyproject.toml +1 -1
- {lbxtoolkit-2.3.0 → lbxtoolkit-2.3.1}/README.md +0 -0
- {lbxtoolkit-2.3.0 → lbxtoolkit-2.3.1}/lbxtoolkit/__init__.py +0 -0
- {lbxtoolkit-2.3.0 → lbxtoolkit-2.3.1}/lbxtoolkit/api_rest.py +0 -0
- {lbxtoolkit-2.3.0 → lbxtoolkit-2.3.1}/lbxtoolkit/auth_entra_id.py +0 -0
- {lbxtoolkit-2.3.0 → lbxtoolkit-2.3.1}/lbxtoolkit/config_manager.py +0 -0
- {lbxtoolkit-2.3.0 → lbxtoolkit-2.3.1}/lbxtoolkit/lbx_logger.py +0 -0
- {lbxtoolkit-2.3.0 → lbxtoolkit-2.3.1}/lbxtoolkit/misc.py +0 -0
- {lbxtoolkit-2.3.0 → lbxtoolkit-2.3.1}/lbxtoolkit/service.py +0 -0
- {lbxtoolkit-2.3.0 → lbxtoolkit-2.3.1}/lbxtoolkit/service_windows.py +0 -0
|
@@ -170,7 +170,7 @@ conexao.close()
|
|
|
170
170
|
raise
|
|
171
171
|
#
|
|
172
172
|
#
|
|
173
|
-
def db_insert_df(self, DataFrame, Tabela, Schema=None, Colunas=None, OnConflict=None, TypeCast=None, Returning=None): # Insere os dados de um dataframe em uma tabela equivalente no banco (exige mesma estrutura de colunas)
|
|
173
|
+
def db_insert_df(self, DataFrame, Tabela, Schema=None, Colunas=None, OnConflict=None, TypeCast=None, Returning=None, Truncar=False): # Insere os dados de um dataframe em uma tabela equivalente no banco (exige mesma estrutura de colunas)
|
|
174
174
|
"""
|
|
175
175
|
Insere um DataFrame no PostgreSQL usando psycopg2 e execute_values().
|
|
176
176
|
|
|
@@ -223,6 +223,15 @@ conexao.close()
|
|
|
223
223
|
try:
|
|
224
224
|
self.Cursor = self.Conexao.cursor()
|
|
225
225
|
|
|
226
|
+
if Truncar:
|
|
227
|
+
try:
|
|
228
|
+
self.Cursor.execute(f"truncate table {Schema}.{Tabela} restart identity cascade;")
|
|
229
|
+
self.Conexao.commit()
|
|
230
|
+
except Exception as Err:
|
|
231
|
+
self.logger.erro(f'{__name__}:Erro [{Err}] ao TRUNCAR a tabela {Schema}.{Tabela}.')
|
|
232
|
+
self.Conexao.rollback()
|
|
233
|
+
raise
|
|
234
|
+
|
|
226
235
|
if Returning:
|
|
227
236
|
Retorno = []
|
|
228
237
|
for valor in Valores:
|
|
@@ -233,7 +242,7 @@ conexao.close()
|
|
|
233
242
|
|
|
234
243
|
self.Conexao.commit()
|
|
235
244
|
except Exception as Err:
|
|
236
|
-
self.logger.erro(f'{__name__}: Erro [{Err}] ao
|
|
245
|
+
self.logger.erro(f'{__name__}: Erro [{Err}] ao INSERIR dados na tabela {Schema}.{Tabela}!')
|
|
237
246
|
self.Conexao.rollback()
|
|
238
247
|
finally:
|
|
239
248
|
self.Cursor.close()
|
|
@@ -263,7 +272,7 @@ conexao.close()
|
|
|
263
272
|
#
|
|
264
273
|
def db_update(self, Query): # Retorna um cursor à partir de um select
|
|
265
274
|
UpdRows = 0
|
|
266
|
-
BlackList = ['INSERT ', 'SELECT ', 'CREATE ', 'DROP ', 'MERGE ', 'REPLACE '
|
|
275
|
+
BlackList = ['INSERT ', 'SELECT ', 'CREATE ', 'DROP ', 'MERGE ', 'REPLACE ' ] ## 'CALL ', 'EXECUTE ' ]
|
|
267
276
|
if any(element in Query.upper() for element in BlackList):
|
|
268
277
|
BlackListed = [element for element in BlackList if element in Query.upper()]
|
|
269
278
|
self.logger.erro(f'{__name__}: Este método permite apenas updates e deletes. A query informada possui as seguintes palavras reservadas não aceitas: {BlackListed} e não foi executada!')
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|