I'm still learning python and I struggle with sql queries
I have a simple table called diverts
column 1 is called chute
column 2 is called five
chute is the primary key and contains Fa01 to Fa60
| chute | five |
|-------|------|
| Fa01 | null |
|-------|------|
| Fa02 | null |
|-------|------|
| Fa03 | null |
|-------|------|
I have a list of values called fiveMin in my script that contains the number of times a specific event relating to that chute happened in a five minute period. I pull this data from elsewhere and populate the list. fiveMin = [1.0, 23.0, 56.0, .... 39.0, 56.0] 60 elements in all
I want to update five column with that data and every five minutes update with the new data not append it.
I have been successful in updating the five column using the following
cursor.executemany('INSERT INTO `ship_diverts` (five) VALUES (%s),(%s),(%s)',
[(item, item, item) for item in fiveMin])
but this just adds data to the five column, I would like to update each column based on the primary key
| chute | five |
|-------|------|
| Fa01 | 1.0 |
|-------|------|
| Fa02 | 23.0 |
|-------|------|
| Fa03 | 56.0 |
|-------|------|
I am not sure how to achieve this, any suggestions?
I also have chute_list = ['Fa01', 'Fa02', .... 'Fa60'] which I can pass in to the query for the primary key.