import MySQLdb DB="geoinfo" LOGIN="gast" PASSWORD="gast" def hl(): print "=" * 80 cnx = MySQLdb.connect(db=DB,user=LOGIN,passwd=PASSWORD) cursor = cnx.cursor() cursor.execute("SELECT * from waypoints order by name") results = cursor.fetchall() hl() print "Total APS:%s" % len(results) hl() f = open('ap.kml','w') f.write('\n') f.write('\n') f.write('\n') f.write('BrestWireless\n') f.write('1\n') for line in results: name = line[0] wep = line[1] lat = line[3] lon = line[4] mac = line[7] print "%s (%s): %s %s" % (name,mac,lat,lon) f.write('\n') f.write(' \n') f.write(' %s\n' % name) #f.write(' \n' % mac) f.write(' \n') f.write(' \n') f.write(' %s\n' % lon) f.write(' %s\n' % lat) f.write(' \n') f.write(' 1\n') f.write(' root://styleMaps#default?iconId=0x307\n') if wep =='WLAN-WEP': f.write(' \n') else: f.write(' \n') f.write(' %s,%s,45\n' % (lon,lat) ) f.write(' \n') f.write('\n') f.write('') hl()