I am using mysqldb to connect to mysql database and I get the metadata/columns in a variable and data/row in another. Now I have to consolidate the list and tuple into a dict and also preserve the order. I know that dicts are orderless but is there any alternative to this?
cursor.description = ['userid', 'cid', 'mid', 'did', 'msid']
data = (29L, 35L, None, '', None)
result = {}
for i in data:
result.update = dict(zip(cols, i))
Expected result
result = {'userid': 29L, 'cid': 35L, 'mid': None, 'did': '', 'msid': None}