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_MacroValuesl'SourceDataset_POSTGRES']
parameters = t
'_HOST', FME_MacroValues3'POSTGRES_IN_HOST_POSTGRES'],
'_PORT', FME_MacroValuesr'POSTGRES_IN_PORT_POSTGRES'],
'_USER_NAME', FME_MacroValuesa'POSTGRES_IN_USER_NAME_POSTGRES'],
'_PASSWORD', FME_MacroValuesE'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()
-----