Example #1
0
    def testHBase(self):
        conf = HBaseConfiguration()
        tablename = "Trees"
        admin = HBaseAdmin(conf)
        if not admin.tableExists(tablename):
            sys.stderr.write('\nERROR - Table name not found:  ' + tablename +
                             '\n\n')
            exit(1)
        # From org.apache.hadoop.hbase.client, create an HTable.
        table = HTable(conf, tablename)
        print 'connection successful'

        # Create the HBaseTable Object.
        hbtable = HBaseTable(tablename, conf, admin)

        # Read a single row from the table.
        rowId = '005430000000000038000163'

        # Put a row into the table.
        row = hbtable.row(rowId)
        row.put('f', 'name', "xxxxxxxxxxxxxxxxxxxxxxx")
        row.tablePut()

        # Read the row back from the table.
        print hbtable.row(rowId).get('f', 'name')
Example #2
0
    def __init__(self, conf=None):
        if conf is None:
            conf = HBaseConfiguration()

        self.hadmin = HBaseAdmin(conf)