月亮看盘,分身情人简谱,邯郸有职招聘网
#!/usr/bin/python
import sys
sys.path.append('/home/zhoujie/downloads/hive-0.7.0-cdh3u0/lib/py')
from hive_service import thrifthive
from hive_service.ttypes import hiveserverexception
from thrift import thrift
from thrift.transport import tsocket
from thrift.transport import ttransport
from thrift.protocol import tbinaryprotocol
hive_server_ip='127.0.0.1'
hive_server_port=10000
#hive_sql='select count(*) from ssp_factbids'
hive_sql="select count(*) from ssp_factbids where logdate_id='20121101'"
def hiveexe(sql):
try:
transport = tsocket.tsocket(hive_server_ip, hive_server_port)
transport = ttransport.tbufferedtransport(transport)
protocol = tbinaryprotocol.tbinaryprotocol(transport)
client = thrifthive.client(protocol)
transport.open()
client.execute(sql)
print "the return value is : "
print client.fetchall()
print "............"
transport.close()
except thrift.texception, tx:
print '%s' % (tx.message)
if __name__ == '__main__':
hiveexe(hive_sql)
如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复
新手学习Python2和Python3中print不同的用法
Python基于os.environ从windows获取环境变量
网友评论