Python Forum

Full Version: merge 3 sql data sets to 1 librairy
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi,

I'm new to Python and I have a problem with list, librairies,...
I have 3 MySQL datasets that I want to merge to 1 librairy. I've tried everything but I can't see the Woods from the trees anymore. I'm sure that for an experienced program this is a very easy problem. Can somebody help me please.

#read iD,tagname and StationID from EWon
db_tagid =  con.cursor()
db_tagid.execute("SELECT Id FROM esync_tags")
df_tagid = db_tagid.fetchall()

db_tagname =  con.cursor()
db_tagname.execute("SELECT Name FROM esync_tags")
df_tagname = db_tagname.fetchall()

db_ewonstationid =  con.cursor()
db_ewonstationid.execute("SELECT StationID FROM esync_tags")
df_ewonstationid = db_ewonstationid.fetchall()
I want to merge this so the librairy looks like this:

all_options = { 
    'ewonstationid1': { 
    'tagname1': tagid1, 
    'tagname2': tagid2, 
    }, 
    'ewonstationid2': { 
    'tagname3': tagid3, 
    'tagname4': tagid4, 
    } 
} 

Sorry, I mean dictionairy, not librairy