def get_candidate_list(db,param):
cursor = db.cursor()
cursor.execute('''SELECT ca.id, ca.fullname, co.id, co.name, p.id, p.name
from candidate ca, candidate_constituency c_c, constituency co, party p
where ca.id=c_c.candidate_id and c_c.constituency_id=co.id and c_c.party_id=p.id ''')
output=[]
for row in cursor.fetchall():
temp={}
temp['candidate_id']=row[0]
temp['candidate_name']=cgi.escape(row[1])
temp['constituency_id']=row[2]
temp['constituency_name']=cgi.escape(row[3])
temp['party_id']=row[4]
temp['party_name']=cgi.escape(row[5])
output.append(temp)
return json.dumps(output);
评论列表
文章目录