candidate.py 文件源码

python
阅读 21 收藏 0 点赞 0 评论 0

项目:electioncharts 作者: mickeykedia 项目源码 文件源码
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);
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号