Access Hypertable via Django and Python on Apache

from django.http import HttpResponse

import sys
from hypertable.thriftclient import *
from hyperthrift.gen.ttypes import *

def index(request):
try:
client = ThriftClient(“localhost”, 38080)
print “HQL examples”
res = client.hql_query(“show tables”)
print res
res = client.hql_query(“select * from thrift_test”)
print res

print “mutator examples”;
mutator = client.open_mutator(“thrift_test”, 0, 0);
client.set_cell(mutator, Cell(“py-k1″, “col”, None, “py-v1″))
client.flush_mutator(mutator);

print “scanner examples”;
scanner = client.open_scanner(“thrift_test”,
ScanSpec(None, None, None, 1), True);

while True:
cells = client.next_cells(scanner)
if (len(cells) == 0):
break
print cells

except:
print sys.exc_info()
raise
return HttpResponse(“Hello, Django2.” + repr(res))

Leave a Reply

You must be logged in to post a comment.