I have the following code:
idDiff = rupleID[0] - 19
cursor.execute("SELECT price FROM table WHERE id BETWEEN '%s' AND '%s';", (idDiff,rupleID[0]))
allPrice = cursor.fetchall()
rupleAprice = [float(i[0]) for i in allPrice]
movAvg = sum(rupleAprice)/20
movlAvg = str(movAvg)
cursor.execute ("UPDATE trading SET movingavg = '%s' ORDER BY id DESC LIMIT 1;", (movlAvg))
conn.commit()
print ("Successful Input Of: " + movlAvg)
What is happening:
Whenever the movingavg column is updated - I receive %s in the row, not whatever number is printed below with "Successful Input Of: (someNumber)
The '%s' works fine in the other 4 functions being called - this is the only row and column that is displaying %s in the table "trading".
Here are some print out's from the python 3 script and of the SQL table:
Successful Input Of: 183.68449999999999
Successful Input Of: 183.68449999999999
Successful Input Of: 183.68449999999999
Successful Input Of: 183.68449999999999
Successful Input Of: 183.685
Successful Input Of: 183.68449999999999
^C-- Goodbye! --
ID | SomeData | movingAvg
| 51 | 182.50000000 | %s | NULL | NULL | NULL | 1516176541 |
+----+--------------+-----------+------+-------+--------+------------+
51 rows in set (0.00 sec)
Anyone shed some light on the issue here? Any pointers would be appreciated.