我现在要把数据从正式服中获取,然后在从测试服中存储
import happybase
import requests
import json
port_hbase=9090
host_hbase='你的正式服ip'
def scanner(table='DATAETL:RPT',start='',end='',*args,**kwrgs):
c=happybase.Connection(host_hbase,port_hbase)
t=c.table(table)
return t.scan(*args,**kwrgs,row_start=start,row_stop=end)
def hbase_save(table='DATAETL:RPT',key='',row='',*args,**kwrgs):
c=happybase.Connection("你的测试服ip",9090)
t=c.table(table)
t.put(key,row)
row_start='2019-10-17_41898936'
row_end='2019-10-17_41898937'
for key,row in scanner(start=row_start,end=row_end):
hbase_save(key=key,row=row)
查询一下,看看ok不, 这里只用扫描一下测试服的这个rowkey
import happybase
import requests
import json
port_hbase=9090
host_hbase='你的测试服ip'
def scanner(table='DATAETL:RPT',start='',end='',*args,**kwrgs):
c=happybase.Connection(host_hbase,port_hbase)
t=c.table(table)
return t.scan(*args,**kwrgs,row_start=start,row_stop=end)
row_start='2019-10-17_41898936'
row_end='2019-10-17_41898937'
for key,row in scanner(start=row_start,end=row_end):
print(key)
成功!