Solved

Oracle Spatial to SHAPE

  • 19 February 2015
  • 27 replies
  • 17 views


Show first post

27 replies

Userlevel 2
Badge +17
I was able to reproduce the error (Error getting format properties for ... reader) only if I made a typo for the format name. I cannot specify the error reason, if you surely entered the format name correctly.

 

If so, could you please paste your Python script as-is except username and password?

 

Userlevel 4
Badge +13
In FME 2015, you can select one of "Named Database Connection" or "Exposed (Embedded) Connection Parameters" for a aatabase connection.

 

Using Named Database Connections (http://docs.safe.com/fme/html/FME_Desktop_Documentation/FME_Desktop_Help.htm#../Subsystems/FME_Readers_Writers/Content/_NamedConnections/Using_Named_Database_Connections.htm)

 

 

Since I used the "Named" connection in the example above, it was not necessary to pass parameters to the "open" method.

 

However, if you publish your workspace to FME Server, possibly you have to use the "Embedded" parameters.

 

This is an example using "Embedded" parameters for the existing POSTGRES reader.

 

-----

 

class SchemaReader(object):        

 

    def input(self, feature):

 

        # Create POSTGRES reader.

 

        # Assuming that the input feature contains comma-delimited table names list

 

        # as an attribute called "table_list".

 

        directives = ['IDLIST', feature.getAttribute('table_list')]

 

        reader = fmeobjects.FMEUniversalReader('POSTGRES', False, directives)

 

        

 

        # Open dataset.

 

        # Assuming that a POSTGRES reader exists in the workspace,

 

        # refer to its Dataset Name and Parameters. 

 

        # The following parameter setting is an example for the POSTGRES format.

 

        # Required parameters are different depending on the format.

 

        # To learn more about parameters, see "Mapping File Directives" section

 

        # of help documentation on the specific format.

 

        dataset = FME_MacroValues['SourceDataset_POSTGRES']

 

        parameters = [

 

            '_HOST', FME_MacroValues['POSTGRES_IN_HOST_POSTGRES'],

 

            '_PORT', FME_MacroValues['POSTGRES_IN_PORT_POSTGRES'],

 

            '_USER_NAME', FME_MacroValues['POSTGRES_IN_USER_NAME_POSTGRES'],

 

            '_PASSWORD', FME_MacroValues['POSTGRES_IN_PASSWORD_POSTGRES'],

 

        ]

 

        reader.open(dataset, parameters)

 

        

 

        while True:

 

            schema = reader.readSchema()

 

            if schema == None:

 

                break

 

            

 

            # Set Feature Type Name.

 

            schema.setAttribute('fme_feature_type', schema.getFeatureType())

 

            

 

            # Create "attribute{}".

 

            for i, name in enumerate(schema.getSequencedAttributeNames()):

 

                type = schema.getAttribute(name)

 

                schema.setAttribute('attribute{%d}.name' % i, name)

 

                schema.setAttribute('attribute{%d}.fme_data_type' % i, type)

 

                

 

            # Ouput Schema Feature.

 

            self.pyoutput(schema)

 

            

 

        reader.close()

 

-----

See also Takashi's blog at http://fme-memorandum-takashi.blogspot.ca/2015/03/create-schema-features-with-python.html and the comments there.

Reply