Collect departmental staff two times recommended Python script--reference

Source: Internet
Author: User

#!/usr/bin/env python#encoding:utf-8import mysqldbtell_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)   &NBSp;       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&nbsP Error ", E

This article from "Chocolee" blog, declined reprint!

Collect departmental staff two times recommended Python script--reference

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.