Premise that i'm still looking for other solutions, my data is printed like this and the rows are tripled:
('iMac 24', '24', 'Apple', 8)
('iMac 24', '24', 'Apple', 9)
('iMac 24', '24', 'Apple', 10)
('HP 24', '24-Cb1033nl', 'HP', 7)
('HP 24', '24-Cb1033nl', 'HP', 6)
('HP 24', '24-Cb1033nl', 'HP', 7)
I want to print them in one rows and group the votes. So I would like to get:
('iMac 24', '24', 'Apple', [8, 9, 10])
('HP-24', '24-Cb1033nl', 'HP', [7, 6, 7])
My code is:
mydb = cursor_test.execute("SELECT product, model, creator, vote FROM sales")
for row in mydb.fetchall():
print(row)
The output of this code is the one shown above where the products triple
Thank you