def check_pk(self, table, fields):
    'Check Primary key to ensure there are not duplicates'
    if ('where' in fields.lower()):
        (fields, where_clause) = fields.lower().split('where')
        where_clause = ('where ' + where_clause)
    else:
        where_clause = ''
    sql = "\n    select\n      '{table}' as table,\n      case when count(1) = count({fields}) then 'PASS' else 'FAIL' end as pk_result\n    from {table}\n    {where_clause}\n    ".format(table=table, fields=fields, where_clause=where_clause)
    data = self.query(sql, echo=False)
    headers = self._fields
    print(ptable(headers, data))
    if (data[0].pk_result == 'FAIL'):
        raise Exception('PK Text failed for table "{}" with fields "{}"'.format(table, fields))
Check Primary key to ensure there are not duplicates
def check_pk(self, table, fields):
    
    if ('where' in fields.lower()):
        (fields, where_clause) = fields.lower().split('where')
        where_clause = ('where ' + where_clause)
    else:
        where_clause = 
    sql = "\n    select\n      '{table}' as table,\n      case when count(1) = count({fields}) then 'PASS' else 'FAIL' end as pk_result\n    from {table}\n    {where_clause}\n    ".format(table=table, fields=fields, where_clause=where_clause)
    data = self.query(sql, echo=False)
    headers = self._fields
    print(ptable(headers, data))
    if (data[0].pk_result == 'FAIL'):
        raise Exception('PK Text failed for table "{}" with fields "{}"'.format(table, fields))