I have a table (history_price) with 2 columns (asset_id and volume) with a lot of NULL lines that I want to fill.
1- I have the following to identify the NULL
mycursor.execute(f"SELECT `Ticker`,`Price`,`Quantity` FROM `history_price` WHERE `volume` IS NULL;")
2- I have the following to find asset_id for each ticker
mycursor.execute(f"SELECT `asset_id` FROM `param_asset` WHERE `param_asset`.`Ticker` LIKE '{ticker}';")
for y in mycursor:
result = y[0]
return result
3- I have the following to fill asset_id
mycursor.execute(f"INSERT INTO `history_price` (asset_id) VALUES (%s)",
4- I have the following to calculate the volume
volume = float(price) * float(quantity)
5-I have the following to insert the volume in the table
mycursor.execute(f"INSERT INTO `history_price` (volume) VALUES (%s)",
Right now they are running as multiple queries in multiple loops, but I am sure I can just join the tables, calculate and fill in one single neat query... Help please