cursor fetchall 28 29 to list

Solutions on MaxInterview for cursor fetchall 28 29 to list by the best coders in the world

showing results for - "cursor fetchall 28 29 to list"
Lorraine
27 Nov 2016
1And what about list comprehensions? If result is ((123,), (234,), (345,)):
2
3>>> row = [item[0] for item in cursor.fetchall()]
4>>> row
5[123, 234, 345]
6
7If result is ({'id': 123}, {'id': 234}, {'id': 345}):
8
9>>> row = [item['id'] for item in cursor.fetchall()]
10>>> row
11[123, 234, 345]
12
13--César