My current script saves to an excel file but i would like to directly upload it to my mysql database.
for i in range(0, len(names)):
ws.append([names[i], str((float(sells[i])+float(buys[i]))/2.0)])
except:
print('Cannot fetch from this link')
print('Saving the file with name markets.xlsx')
wb.save("markets.xlsx")
how would i perform a loop to do the following
sql = "INSERT INTO todaysmarkets(Name,value) VALUES(%s,%s)"
****Update*****
following the advice on here i now have the following:
cnx = mysql.connector.connect(host='.com', user='', password='', database='')
cursor = cnx.cursor()
for i in range(0, len(names)):
cursor.execute(("INSERT INTO todaysmarkets(Name,value) VALUES(%s,%s)"), (names[i], str((float(sells[i])+float(buys[i]))/2.0)))
cnx.close()
script runs through with no errors but the database is not updated.