首页 > 编程语言 > 详细

收集部门人员一次二次推荐python脚本--参考

时间:2014-10-15 14:21:42      阅读:241      评论:0      收藏:0      [点我收藏+]
#!/usr/bin/env python
#encoding:utf-8
import MySQLdb
tell_file=‘/home/test/liyiliang/study/tell.info‘
f = file(tell_file)
account_list = f.readlines()
f.close()
for n in account_list:
  h=n.strip().split()
  name = h[0]
  phone = h[1]
  try:
    conn = MySQLdb.connect(host=‘x.x.x.x‘,user=‘xxxx‘,passwd=‘xxxxxxx‘,port=xxxxx,charset=‘utf8‘)
    cur = conn.cursor()
    cur.execute(‘select promotioncode from cinf_db.cinf_promotioncode where mp = %s‘,phone)
    mycode = cur.fetchall()
    numTwo=0
    for code in mycode:
      cur.execute(‘select mp from cinf_db.cinf_promotioncode_reward_history where reward_type=1 and promotioncode = %s‘,code)
      op = cur.fetchall()
      cur.execute(‘select count(*) from cinf_db.cinf_promotioncode_reward_history where reward_type=1 and promotioncode= %s ‘,code)
      mynum = cur.fetchall()
      for opnum in op:
        cur.execute(‘select promotioncode from cinf_db.cinf_promotioncode  where mp = %s‘,opnum)
        othercode = cur.fetchall()
        for oc in othercode:
          cur.execute(‘select count(*) from cinf_db.cinf_promotioncode_reward_history where reward_type=1 and promotioncode = %s‘,oc)
          everone = cur.fetchall()
          for a in everone:
            b=int(a[0])
            numTwo += b
      for numOne in mynum:
        print ‘%s‘ %name,
        print ‘%s‘ %phone,
        print ‘%s‘ %numOne,
        print ‘%s‘ %numTwo
            
        
    cur.close()
    conn.close()
  except MySQLdb.Error,e:
    print "MySQLdb Error",e

 

本文出自 “Chocolee” 博客,谢绝转载!

收集部门人员一次二次推荐python脚本--参考

原文:http://chocolee.blog.51cto.com/8158455/1564197

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!