Database Reference
In-Depth Information
import sys
import os
import time
from thrift.transport import TTransport
from thrift.transport import TSocket
from thrift.transport import THttpClient
from thrift.protocol import TBinaryProtocol
from hbase import THBaseService
from hbase.ttypes import *
# Add path for local "gen-py/hbase" for the pre-generated module
gen_py_path = os.path.abspath('gen-py')
sys.path.append(gen_py_path)
print "Python & HBase Demo using thrift"
host = "localhost"
port = 9090
framed = False
socket = TSocket.TSocket(host, port)
if framed:
transport = TTransport.TFramedTransport(socket)
else:
transport = TTransport.TBufferedTransport(socket)
protocol = TBinaryProtocol.TBinaryProtocol(transport)
# Getting Thrift client instance
client = THBaseService.Client(protocol)
#Opening socket Connection with HBase
transport.open()
table = "tab1"
# Create the PUT call
put = TPut(row="row-1", columnValues=[TColumnValue(family="cf1",qualif
ier="greet",value="Hello")])
print "Putting Data:", put
 
Search WWH ::




Custom Search