Skip to main content
Hi,

 

 

I am trying to open an Oracle table using FME through python but I seem to

 

be missing something. readSchema() keeps complaining:

 

'The tables which are to be used for translation must be specified'

 

 

This is the code:

 

 

import fmeobjects

 

  reader = fmeobjects.FMEUniversalReader('ORACLE8i',False) 

 

  parameters = p'SERVER_TYPE','ORACLE8i'

 

                          ,'USER_NAME','<username>'

 

                          ,'PASSWORD','<password>'

 

                          ,'WORKSPACE', 'LIVE'                       

 

                          ,'TABLELIST','<schema>.<tablename>']

 

  reader.open('<TNS_Name>',parameters)

 

  schema = reader.readSchema()

 

 

Thank you for your time!

 

Sirko
Hi,

 

 

I recommend you do something like this:

 

 

sourceFormat, sourceDataset, directives = fmeobjects.FMEDialog().sourcePrompt('', '', 9])

 

print sourceFormat

 

print sourceDataset

 

print directives

 

 

This way you can use the interactive GUI dialog to construct your parameters and copy/paste them into your code. It's a lot easier to get something going this way.

 

 

David
Hi David,

 

 

Thank you for your response.

 

 

foo = dialog.sourcePrompt("ORACLE8i",'<TNS_Name>',parameters)

 

 

Using dialog.sourcePrompt()  was how I started to begin with. The key - value pairs I added to the parameters are derived from it but unfortunately I am still not getting any different results.

 

 

reader.readSchema() still fails like above and reader.read() returns nothing.

 

 

It would be great if someone could post an example or a link other than

 

http://docs.safe.com/fme/html/FME_Objects_Python_API/index.html to do some RTFM.

 

 

Cheers,

 

Sirko

 


OK my bad David was right, after I passed the directives to fmeobjects.FMEUniversalReader()

 

things went as expected so I went and did this:

 

 

def get_oracle_directive(self,layer):

 

 

        oracle_macros = {'SERVER_TYPE':'ORACLE8i','USER_NAME':self.ORACLE_USER,'PASSWORD':self.ORACLE_PASSWORD

 

                         ,'WORKSPACE':'','PERSISTENT_CONNECTION':'YES','SHOW_SYSTEM_TABLES':'NO'

 

                         ,'REMOVE_SCHEMA_QUALIFIER':'NO','READ_3D_POLYGON_AS_FACE':'NO','TABLELIST':layer

 

                         ,'WHERE_CLAUSE':'','PARSE_MAPINFO_SYMBOLOGY':'NO','MAPINFO_SYMBOLOGY_STYLE_COLUMN':''

 

                         ,'MAPINFO_SYMBOLOGY_INDEX_COLUMN':'','EXPOSE_ATTRS_GROUP':'','ORACLE8I_EXPOSE_FORMAT_ATTRS':''

 

                         ,'USE_SEARCH_ENVELOPE':'NO','SEARCH_ENVELOPE_MINX':'0','SEARCH_ENVELOPE_MINY':'0'

 

                         ,'SEARCH_ENVELOPE_MAXX':'0','SEARCH_ENVELOPE_MAXY':'0','CLIP_TO_ENVELOPE':'NO',

 

                         }

 

       

 

        directives = ,]

 

        directives.append('ORACLE8I')

 

        directives.append(self.ORACLE_TNS_NAME)

 

        directives.append('RUNTIME_MACROS')

 

        runtime_marcos = ''

 

        for o in oracle_macros:

 

            runtime_marcos = runtime_marcos + o + ',' + oracle_macrospo] + ','           

 

        runtime_marcos = runtime_marcos +'_MERGE_SCHEMAS,YES'       

 

        directives.append(runtime_marcos)

 

        directives.append('META_MACROS')

 

        meta_macros = ''

 

        for o in oracle_macros:

 

            meta_macros = meta_macros + 'Source' + o + ',' + oracle_macrospo] + ','

 

        meta_macros = re.sub(',$','',meta_macros)

 

        directives.append(meta_macros)

 

        directives.append('METAFILE')

 

        directives.append('ORACLE8I')

 

        directives.append('COORDSYS')

 

        directives.append('')

 

        directives.append('IDLIST')

 

        directives.append(layer)

 

 

        return directives

Reply