Skip to content

Instantly share code, notes, and snippets.

@srs81
Last active December 25, 2015 17:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save srs81/7012106 to your computer and use it in GitHub Desktop.
Save srs81/7012106 to your computer and use it in GitHub Desktop.
import happybase, sys, os, string
# VARIABLES
# HBase Thrift server to connect to. Leave blank for localhost
server = ""
# Connect to server
c = happybase.Connection(server)
# Get the full list of tables
tables = c.tables()
# For each table in the tables
for table in tables:
t = c.table(table)
print table + ": ",
rowCount = 0
colCount = 0
# For each row key
for prefix in string.printable:
try:
for key, data in t.scan(row_prefix=prefix):
rowCount += 1
# Each column
for col in data:
colCount += 1
except:
os.system("hbase-daemon.sh restart thrift")
c = happybase.Connection(server)
t = c.table(table)
continue
print "%d, %d" % (rowCount, colCount)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment