pythonhbasehappybase

row_prefix in happybase table.scan not working with str variable


I am using the row_prefix in the table.scan method to filter the rows. The problem is that the function works when a string literal is used. However, if a variable is used no data is returned.

For example, the following code is working

connection = happybase.Connection(connect string)
table = connection.table('table')
table = table.scan(row_prefix='abc001', include_timestamp=False)

But the following code does not return any data

connection = happybase.Connection(connect string)
table = connection.table('table')

query = '\'{0}{1}\''.format(args['str1'], args['str2'])
table = table.scan(row_prefix=query, include_timestamp=False)

There is no error in the 2nd case.


Solution

  • replace '\'{0}{1}\'' with '{0}{1}' in query value and try again