Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Debianized Egg of the Thrift client for HBase

README.mkd

Pyhon-HBase

This package can be used to generate a Python egg for the HBase thrift bindings.

Installation

$ sudo add-apt-repository "deb http://apt.pub.simplegeo.com/ubuntu foss-development main"
$ sudo aptitude update
$ sudo aptitude install simplegeo-keyring
$ sudo aptitude update
$ sudo aptiutde install python-hbase-thrift

OR

$ make sdist
$ sudo easy_install dist/*.tar.gz

Usage

#!/usr/bin/env python
import sys

from thrift import Thrift
from thrift.transport import TSocket
from thrift.transport import TTransport
from thrift.protocol import TBinaryProtocol

from hbase import Hbase
from hbase.ttypes import *

# Make socket
transport = TSocket.TSocket('localhost', 9090)

# Buffering is critical. Raw sockets are very slow
transport = TTransport.TBufferedTransport(transport)

# Wrap in a protocol
protocol = TBinaryProtocol.TBinaryProtocol(transport)

client = Hbase.Client(protocol)
transport.open()

print client.getTableNames()

desc = ColumnDescriptor( { 'name' : 'foo:' } )
client.createTable('our_table', [desc])
print client.getTableNames()
Something went wrong with that request. Please try again.