def insertData(data): insert_sql = ''' INSERT INTO `headerinfo1` (`re_time`, `uid`, `mid`, `box_status`, `from_addree`, `seed_email`, `domain_name`, `sender`, `subject`, `box_id`) VALUES ('%s', %s, %s, %s, '%s', '%s', '%s', '%s', '%s', '%s'); ''' try: insert_conn = mdb.get_vmware_conn() datas = mdb.exe_sql(insert_conn, insert_sql % data, False, True) except Exception, e: print 'Insert data to Mysql error: %s' %e
def getEmailuid(email_address): get_maxid_sql = ''' select max(h.box_id) as max_uid from headerinfo1 h where h.seed_email = '%s' ''' try: select_conn = mdb.get_vmware_conn() uid = mdb.exe_sql(select_conn, get_maxid_sql % email_address, True, True) return uid[0]['max_uid'] except Exception, e: print 'Select the max uid error: %s' %e
def getSeedemail(): get_seed_sql = ''' select ge.email_address,ge.domain_name,ge.password from global_seed_emails ge where ge.domain_name in ('163.com', '126.com', 'sina.com', 'sina.cn', 'sohu.com') order by ge.domain_name; ''' try: get_seed_conn = mdb.get_vmware_conn() datas = mdb.exe_sql(get_seed_conn, get_seed_sql, True, True) return datas except Exception, e: print 'Get data from Mysql error: %s' %e
def getSeedemail(domain_name): get_seed_sql = ''' select ge.email_address,ge.domain_name,ge.password from global_seed_emails ge where ge.domain_name in ( %s ) order by ge.domain_name; ''' try: get_seed_conn = mdb.get_vmware_conn() # print get_seed_sql % domain_name datas = mdb.exe_sql(get_seed_conn, get_seed_sql % domain_name, True, True) return datas except Exception, e: print 'Get data from Mysql error: %s' %e