def query_by_table_type(tablename, db, request=request):
    keyed = hasattr(db[tablename], '_primarykey')
    if keyed:
        firstkey = db[tablename][db[tablename]._primarykey[0]]
        cond = '>0'
        if firstkey.type in ['string', 'text']:
            cond = '!=""'
        qry = '%s.%s.%s%s' % (
            request.args[0], request.args[1], firstkey.name, cond)
    else:
        qry = tuple(request.args[:2]) % '%s.%s.id>0'
    return qry


# ##########################################################
# ## list all databases and tables
# ###########################################################
dataset/ETHPy150Open codeupstudio/chipincode/controllers/appadmin.py/query_by_table_type/swapped operands of `%`