I'm having issues trying to stop my script to not insert a new row if the icl_dollar_amount is already in my table. Every time I run my script it inserts a new row.
ppc_data.icl_awk table
client id file total
12345 2000.45
actual result
client id file total
12345 2000.45
12345 2000.45
expected result
client id file total
12345 2000.45
code:
body_l =[]
for link in url:
browser = webdriver.Chrome(options=options,
executable_path=r'\TESTuser$TESTDocumentschromedriver.exe')
# if 'P2 Cust ID 908554 File' in fcg_subject:
browser.get(link)
body = browser.find_element_by_xpath("//*[contains(text(), 'Total:')]").text
body_l.append(body)
icl_dollar_amount = re.findall('(?:[£$€]{1}[,d]+.?d*)', body)[0].split('$', 1)[1]
icl_dollar_amount_l.append(icl_dollar_amount)
if not missing_amount:
logging.info("List is empty")
print("List is empty")
count = 0
for i in range(len(missing_amount)):
if missing_amount[i] in icl_dollar_amount_l:
body = body_l[i]
get_company_id = body.split("Customer Id:", 1)[1][4:10].strip()
client_id_l.append(get_company_id)
get_file_total = re.findall('(?:[£$€]{1}[,d]+.?d*)', body)[0].split('$',1)[1]
file_total_l.append(get_file_total)
return client_id_l, file_total_l
def insertToDb(client_id_l, file_total_l):
for client_id, file_total in
zip(client_id_l,file_total_l):
if client_id == '000908554':
ins_file_dtl = """INSERT INTO ppc_data.icl_awk VALUES ('%s', %s)""" % (client_id, file_total)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…