I have the below mysql table. I need to pull out the first two rows as a dictionary using python. I am using python 2.7.
C1 C2 C3 C4 C5 C6 C7
25 33 76 87 56 76 47
67 94 90 56 77 32 84
53 66 24 93 33 88 99
73 34 52 85 67 82 77
I use the following code
exp = MySQLdb.connect(host,port,user,passwd,db)
exp_cur = van.cursor(MySQLdb.cursors.DictCursor)
exp_cur.execute("SELECT * FROM table;")
data = exp_cur.fetchone()
data_keys = data.keys()
#print data_keys
The expected output (data_keys) is
['C1', 'C2', 'C3', 'C4', 'C5', 'C6', 'C7']
But I get
['C1', 'C3', 'C2', 'C5', 'C4', 'C7', 'C6']
What is the mistake in my code?