How to display timestamp while scanning hbase?

261 views Asked by At
for key, data in table.scan():
print('Found: {}, {}'.format(key, data))

I have an HBase table that I need to scan and print the timestamp. I have written the above code but it only produces output like...

Found: b'row1', {b'cf1:col':(b'value')}

But I want output like...

Found: b'row1', {b'cf1:col':(b'value', timestamp)}

Any idea guys?

1

There are 1 answers

0
Nipuna Upeksha On

By default, HBase does not include timestamps in the results you return. You can use HappyBase to retrieve them. To get them, your application needs to have timestamps_include,

row = table.row(b'row-key', columns=[b'cf1:col1'], include_timestamp=True)
value, timestamp = row[b'cf1:col1']

And after that, you can use,

for key, data in table.scan(include_timestamp=True):
   print('Found: {}, {}'.format(key, data))