I have the below code:
import MySQLdb
import sys
import pprint
connect = MySQLdb.connect(host = "127.8.2.3", port=3377, user = "root", db="data1")
with connect:
cur = connect.cursor()
cur.execute("SELECT familynames,names FROM data1.files")
rows = cur.fetchall()
pprint.pprint(rows)
I want to create a big dictionary which has "family names" as key and "names" as the value.Further, the value of the big dict(names), should again be a dict itself with key=names and value= number of identical names under the same family name.
I have tried the DictCursor function of MySQLPython but it is not capable of creating dict within dict.
I also have tried to make a loop over each item of the big dict to split and create another smaller dict(for values of the big dict) but since the returned result of the cur.execute is a Tuple that is not possible as well.
Can someone help me in this regards?