def update_university_latlng(): sql1 = "select id,university from university_list where id > '234' " sql4 = "update university_list set latlng = %s where id = %s" db = cdb.DatabaseConnection() cur,con = db.dbConnect('lyq_sy_db') cur.execute(sql1) all_university = cur.fetchall() univer = [] for i in all_university: temp = [] # print "type:",type(i[1]) # university_id = i[0] name = i[1].encode('utf-8') latlng = map.getlnglat(name) temp.append(latlng)#坐标 temp.append(i[0])#id univer.append(temp) cur.executemany(sql4,univer) con.commit() cur.close() print '插入完成'
def update(): sql1 = "select id,yiyuan from doc_msg3 " sql4 = "update doc_msg3 set city = %s,lnglat = %s where id = %s" db = cdb.DatabaseConnection() cur,con = db.dbConnect('lyqystj') cur.execute(sql1) all_hos = cur.fetchall() hos = [] for i in all_hos: temp = [] print 'hos:',i[1] print 'hos_type:',type(i[1].encode('utf-8')) lnglat = map.getlnglat(i[1].encode('utf-8')) if(lnglat != 'false'): city = map.getReverse_lnglat(lnglat) temp.append(city) # city temp.append(lnglat) # lnglat temp.append(i[0]) hos.append(temp) cur.executemany(sql4,hos) con.commit() cur.close() print '插入完成'