日韩久久久精品,亚洲精品久久久久久久久久久,亚洲欧美一区二区三区国产精品 ,一区二区福利

Hbase使用(python3.6版)

系統 2021 0

參考腳本之家

首先,安裝thrift

thrift鏈接:https://github.com/SparksFly8/Tools

下載thrift,這里用的是thrift-0.7.0-dev.tar.gz 這個版本

            
              tar xzf thrift-0.7.0-dev.tar.gz

cd thrift-0.7.0-dev

sudo ./configure --with-cpp=no --with-ruby=no

sudo make

sudo make instal
            
          

src/main/resources/org/apache/hadoop/hbase/thrift/然后,到HBase的源碼包里,找到

執行

thrift --gen py Hbase.thrift
mv gen-py/hbase/ /usr/lib/python3.6.2/site-packages/ (根據python版本可能有不同)

            
              # coding:utf-8
 
from thrift import Thrift
from thrift.transport import TSocket
from thrift.transport import TTransport
from thrift.protocol import TBinaryProtocol
from hbase import Hbase
import hbase.ttypes 
 
import csv 
 
def client_conn():
 transport = TSocket.TSocket('hostname,like:localhost', port)
 transport = TTransport.TBufferedTransport(transport)
 protocol = TBinaryProtocol.TBinaryProtocol(transport)
 client = Hbase.Client(protocol)
 transport.open()
 return client
 
if __name__ == "__main__":
 
 client = client_conn()
 result = client.getRow("table name","row name")
 data_simple =[]
 for k, v in result[0].columns.items(): #.keys()
    data_simple.append((v.timestamp, v.value))
 writer.writerows(data)
 csvfile.close()
 csvfile_simple = open("data_xy_simple.csv", "wb")
 writer_simple = csv.writer(csvfile_simple)
 writer_simple.writerow(["timestamp", "value"])
 writer_simple.writerows(data_simple)
 csvfile_simple.close()
 print(finished)
            
          

?


更多文章、技術交流、商務合作、聯系博主

微信掃碼或搜索:z360901061

微信掃一掃加我為好友

QQ號聯系: 360901061

您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描下面二維碼支持博主2元、5元、10元、20元等您想捐的金額吧,狠狠點擊下面給點支持吧,站長非常感激您!手機微信長按不能支付解決辦法:請將微信支付二維碼保存到相冊,切換到微信,然后點擊微信右上角掃一掃功能,選擇支付二維碼完成支付。

【本文對您有幫助就好】

您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描上面二維碼支持博主2元、5元、10元、自定義金額等您想捐的金額吧,站長會非常 感謝您的哦!!!

發表我的評論
最新評論 總共0條評論
主站蜘蛛池模板: 民丰县| 永春县| 石渠县| 保康县| 乌什县| 福泉市| 玉门市| 赫章县| 临武县| 大悟县| 保亭| 昌平区| 甘孜| 三门峡市| 富阳市| 清水县| 仪陇县| 宜兰县| 岳池县| 永昌县| 渑池县| 庆城县| 财经| 淅川县| 光山县| 澄迈县| 西和县| 横山县| 乌什县| 个旧市| 民乐县| 山阳县| 凯里市| 湖南省| 江津市| 海南省| 玉山县| 安图县| 井研县| 南靖县| 会泽县|