博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
HiveClient
阅读量:7282 次
发布时间:2019-06-30

本文共 1127 字,大约阅读时间需要 3 分钟。

Python

Operates only on a standalone server. Set (and export) PYTHONPATH to build/dist/lib/py.

The python modules imported in the code below are generated by building hive.

Please note that the generated python module names have changed in hive trunk.

#!/usr/bin/env pythonimport sysfrom hive import ThriftHivefrom hive.ttypes import HiveServerExceptionfrom thrift import Thriftfrom thrift.transport import TSocketfrom thrift.transport import TTransportfrom thrift.protocol import TBinaryProtocoltry:    transport = TSocket.TSocket('localhost', 10000)    transport = TTransport.TBufferedTransport(transport)    protocol = TBinaryProtocol.TBinaryProtocol(transport)    client = ThriftHive.Client(protocol)    transport.open()    client.execute("CREATE TABLE r(a STRING, b INT, c DOUBLE)")    client.execute("LOAD TABLE LOCAL INPATH '/path' INTO TABLE r")    client.execute("SELECT * FROM r")    while (1):      row = client.fetchOne()      if (row == None):        break      print row    client.execute("SELECT * FROM r")    print client.fetchAll()    transport.close()except Thrift.TException, tx:    print '%s' % (tx.message)

转载地址:http://yxzjm.baihongyu.com/

你可能感兴趣的文章
工作中要拿出自己的态度
查看>>
一不留神,勒索软件“改头换面”,如何抵御
查看>>
英飞凌与SkyTerra和TerreStar开发SDR移动通信平台
查看>>
5G是爱情,基于现实基础才更甜蜜
查看>>
芯科Blue Gecko SoC瞄准Bluetooth Smart应用
查看>>
呼和浩特“四个着力”瞄准中国云计算中心
查看>>
市场聚焦:美国民用安防DIY需求大
查看>>
云存储究竟是什么?
查看>>
直播行业红利可观,让星域CDN和云计算业务为迅雷贡献了三成营收
查看>>
“十三五”光伏发电能否破局 就看这六点了
查看>>
澳大利亚国防部更新云战略
查看>>
测试试卷-设计发表QQ说说功能列表和测试用例
查看>>
办公管理服务Service Partner One获千万美元A轮融资
查看>>
大数据欲立法 众专家把脉规则建立
查看>>
《淘宝店铺营销推广一册通》一1.5 搜索优化之产品发布
查看>>
第四大移动操作系统诞生:万万没想到是它
查看>>
你所不知道的 EMC 开源的那些事
查看>>
《大规模元搜索引擎技(1)》一2.3 挑战环境
查看>>
《数据结构与算法 C语言版》—— 1.7上机实验
查看>>
关于 Git 你所不知道的一些事
查看>>