#coding: utf-8
importsys
reload(sys)
sys.setdefaultencoding('utf-8')importtimeimportdatetimeimportsmtplibimportosfrom pyhive importhiveimportnumpy as npimportpandas as pdfrom email.mime.multipart importMIMEMultipartfrom email.mime.text importMIMETextfrom email.mime.image importMIMEImagefrom email.header importHeaderimportlogging#连接hive数据库,读取原始数据#try_except_else 语句,如果在try子句执行时没有发生异常,Python将执行else语句后的语句
def sqldf(sql,username='xxx',password='xxx',host ='xxx',port = xxx,database = 'xxx', auth="xxx"):
_conn_status=True
_max_retries_count= 1 #设置最大重试次数
_conn_retries_count = 1 #初始重试次数
_conn_retry_time = 1 #重试等待时间为30秒
while _conn_status and _conn_retries_count <=_max_retries_count:try:
conn= hive.Connection(username = username, password = password, dat