'Return a list of (column_name, referenced_table_name, referenced_column_name)
for all key columns in the given table.'

def get_key_columns(self, cursor, table_name):

    key_columns = []
    cursor.execute('\n                                                SELECT    column_name,    referenced_table_name,    referenced_column_name\n                                                FROM    information_schema.key_column_usage\n                                                WHERE    table_name    =    %s\n                                                                AND    table_schema    =    DATABASE()\n                                                                AND    referenced_table_name    IS    NOT    NULL\n                                                                AND    referenced_column_name    IS    NOT    NULL', [table_name])
    key_columns.extend(cursor.fetchall())
    return key_columns
