Let's see if I can ask the right questions the right way. I am trying to put 
the results of a MySQL query into a dictionary. It fails because it includes 
the Unicode delimiter - "u'somevalue'". Can someone tell me the right way to do 
this, please?



Thank you,

Shawn



csdbConn = zxJDBC.connect("jdbc:mysql://myhost:3306/mydb", "User", "Password", 
"com.mysql.jdbc.Driver")



csdbCursor = csdbConn.cursor(1)



envsql = "select envVariable, envValue from ODS_ENV_DICT where envName = 'ST2'"

print 'envsql: ' + envsql



csdbCursor.execute(envsql)



envDict = {}

for envVariable, envValue in csdbCursor.fetchall():

    print envVariable, envValue

    envDict[envVariable].append(envValue)



csdbCursor.close()

csdbConn.close()



------------------
envsql: select envVariable, envValue from ODS_ENV_DICT where envName = 'ST2'
envDB systest2
Traceback (most recent call last):
  File "H:\workspace\test\src\root\nested\example.py", line 33, in <module>
    envDict[envVariable].append(envValue)

KeyError: u'envDB'
_______________________________________________
Tutor maillist  -  [email protected]
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to