This is the section of code (Note: this is only my second attempt at writing a program):-
su_stat = [] indx = 0 sql = ('SELECT IFNULL(categories.desc,"Total") as Category, YEAR(trans_dat), sum(transactions.amount) ' 'FROM transactions ' 'inner join vendor on transactions.acct_no = vendor.acct_no ' 'inner join categories on vendor.cat_1 = categories.cat_no ' 'group by cat_1 with rollup ') cursor.execute(sql) su_row = cursor.fetchall() print(su_row) for row in su_row: print(row) su_stat.append(row) for row in su_stat: print(row) my_c1 = row[0] my_amt = str(row[2]) sudat[indx][0] = my_c1 sudat[indx][1] = my_amt indx = indx + 1 print(sudat) print(indx) connection.close()The individual rows are:-
Output:('Food', 2018, Decimal('-31163.28'))
('Car', 2018, Decimal('-29888.81'))
('Entertainment', 2018, Decimal('-10250.68'))
('Health', 2018, Decimal('-22569.32'))
('Transport', 2018, Decimal('-4065.60'))
('Comms', 2018, Decimal('-4367.56'))
('School', 2017, Decimal('-3073.55'))
('House Hold', 2016, Decimal('-29560.66'))
('Travel', 2018, Decimal('-976.04'))
('Personal', 2018, Decimal('-152201.22'))
('Payments', 2016, Decimal('251313.75'))
('Misc', 2018, Decimal('-2319.53'))
('Misc', 2018, Decimal('-39122.50'))