Aug-16-2022, 05:34 PM
(Aug-16-2022, 05:17 PM)ibreeden Wrote: Apparently "row" does not contain what you expect. So in such cases always add a print statement just before the line where the error occurs.
print(row)What does it show?
Furtheron it is good practice to mention the columns you want instead of "select * from ...". Now you choose all columns and only use row[2], row[3] and row[4]. I is better to specify the columns by name so you can be sure you can use row[0], row[1] and row[2]
Quote:{'id': 1, ‘date’: ‘22.05.2022’, ‘product1’: Decimal('0.0'), ‘product2’: Decimal('3.0'), ‘product3’: Decimal('0.0')}
Traceback (most recent call last):
File “/home/pokip/test.py”, line 77, in <module>
print(“{0}”.format(row))
KeyError: 3