I am trying to print out a dictionary result. The dictionary is made from a database search. I have tried to print it in every possible way
here is the code
#!/usr/bin/python
import elementtree.ElementTree as ET
import urllib
import MySQLdb
print "Content-type: text/html\n"
info={}
def find_text(element):
if element.text is None:
for subelement in element:
for txt in find_text(subelement):
yield txt
else:
yield element
# connect
db = MySQLdb.connect(host = "localhost", user = "username", passwd = "password", db = "adamplo1_UniProject")
# create a database cursor
cursor = db.cursor(MySQLdb.cursors.DictCursor)
# execute SQL select statement
cursor.execute("SELECT * FROM Threshold")
Results = cursor.fetchall()
feed = urllib.urlopen("http://server-up.theatticnetwork.net/demo/")
try:
tree = ET.parse(feed)
except Exception, inst:
print "Unexpected error opening %s: %s" % (tree, inst)
root= tree.getroot()
text = root.getchildren()
for element in text:
if element.tag == "Memory":
for element in find_text(element):
print element.tag
print "<br />"
print Results[Free]
print Results['Free']
print Results["Free"]
print Results["'Free'"]
url = http://adamplowman.com/cgi-bin/getting_xml_info%20copy.py