I am trying to read the results for a SQLExecutor. The transformer does not have the possibility to expose schema features. And I would need it (rather than reading the table from the DB with a FeatureReader)
following the advice from the answers for this question:
I am using Python to read the feature name and types and create a schema feature with the format
attribute{n}.fme_data_type
attribute{n}.name
import fme
import fmeobjects
# Template Function interface:
# When using this function, make sure its name is set as the value of
# the 'Class or Function to Process Features' transformer parameter
def processFeature(feature):
feature_attr_names = feature.getAllAttributeNames()
i = 0
for feature_attr_name in feature_attr_names:
feature.setAttribute('attribute{0}.fme_data_type'.format(i), feature.getAttributeType(feature_attr_name))
feature.setAttribute('attribute{0}.name'.format(i), feature_attr_name)
i+=1
pass
When it comes to expose the attributes I create FME does not seem to be able to iterate the creation and I have to insert manually the numbers for every "n". If I do this the resulting schema attribute is created but with round brackets and not curly brackets, and fme_data_type is an number (that is the corresponding variable for FME_data_type as described here.
Has anyone ever managed to accomplish what I am trying to do and could help me?