I have been trying to solve this problem but I cannot get it right :( I am querying mySQL database in Django, and my results comes back as a tuple inside of an array. Please see dummy data below;
query_results = [
(500, datetime.date(2017, 1, 1)),
(302, datetime.date(2017, 1, 2)),
(550, datetime.date(2017, 1, 3)),
(180, datetime.date(2017, 1, 4)),
(645, datetime.date(2017, 1, 5)),
(465, datetime.date(2017, 1,6))
]
500, 302, 550 etc... are my records. The next element are the date of those records. I would like to append them into a dictionary using a loop, but I always get an error of:
TypeError: list indices must be integers, not tuple.
Can anyone please give me some advise on how to append these into something like this:
myDict = {
"record": "",
"date": ""
}
All help is greatly appreciated!