I am pulling data from a MySQL db which comes in as a list.
'''
my_cursor.execute(sql_str)
my_results = my_cursor.fetchall()
print(my_results)
'''
OUTPUT [('Allen, Jamie', 2), ('Anderson, Abbie', 1391), ('Anderson, Marcie', 1380), etc.,etc.
Instead of a list, I want to populate a dictionary.
'''
my_cursor.execute(sql_str)
my_result = {}
my_result = [{'Name': row[0], 'ID': row[1]} for row in my_cursor.fetchall()]
print(my_result)
'''
OUTPUT [{'Name': 'Allen, Jamie', 'ID': 2}, {'Name': 'Anderson, Abbie', 'ID': 1391}, etc.
As you can see I am getting a list of directories not a directory. I really would appreciate your help.
Thanks,
John