add tsa_codice
This commit is contained in:
19
update.py
19
update.py
@ -5,19 +5,19 @@ import math
|
||||
|
||||
value_update = []
|
||||
|
||||
def update_records(connection,codice,prezzo,sc1,sc2,listino,ricarica,codice_barre,codice_alternativo):
|
||||
def update_records(connection,codice,prezzo,sc1,sc2,listino,ricarica,codice_barre,codice_alternativo,tsa_codice):
|
||||
|
||||
try:
|
||||
result = []
|
||||
cursor = connection.cursor()
|
||||
|
||||
if sc1 is not None :
|
||||
if sc1 is not None and not math.isnan(sc1):
|
||||
query_lsa = "UPDATE lsa SET TSM_CODICE = %s WHERE ART_CODICE = %s AND TLA_CODICE = '1'"
|
||||
cursor.execute(query_lsa, (sc1, codice))
|
||||
count = cursor.rowcount
|
||||
result.append(count)
|
||||
|
||||
if sc2 is not None:
|
||||
if sc2 is not None and not math.isnan(sc2):
|
||||
query_lsv_tsm = "UPDATE lsv SET TSM_CODICE = %s WHERE ART_CODICE = %s AND TLV_CODICE = %s"
|
||||
cursor.execute(query_lsv_tsm, (sc2, codice,listino))
|
||||
count = cursor.rowcount
|
||||
@ -47,6 +47,12 @@ def update_records(connection,codice,prezzo,sc1,sc2,listino,ricarica,codice_barr
|
||||
count = cursor.rowcount
|
||||
result.append(count)
|
||||
|
||||
if tsa_codice is not None and not math.isnan(tsa_codice):
|
||||
query_tsa = "UPDATE art SET TSA_CODICE = %s WHERE codice = %s"
|
||||
cursor.execute(query_tsa, (tsa_codice, codice))
|
||||
count = cursor.rowcount
|
||||
result.append(count)
|
||||
|
||||
connection.commit()
|
||||
|
||||
if all(value == 0 for value in result):
|
||||
@ -72,9 +78,12 @@ def update_records(connection,codice,prezzo,sc1,sc2,listino,ricarica,codice_barr
|
||||
codice_barre = 0
|
||||
|
||||
if pd.isna(codice_alternativo):
|
||||
codice_alternativo = 0;
|
||||
codice_alternativo = 0
|
||||
|
||||
if math.isnan(tsa_codice):
|
||||
tsa_codice = 0
|
||||
|
||||
row = [codice,prezzo,listino,sc1,ricarica,codice_barre,codice_alternativo,sc2]
|
||||
row = [codice,prezzo,listino,sc1,ricarica,codice_barre,codice_alternativo,sc2,tsa_codice]
|
||||
value_update.append(row)
|
||||
return value_update
|
||||
|
||||
|
||||
Reference in New Issue
Block a user