Skip to main content
Question

Python Shutdown script to write Workbench parameters to PostGreSQL

  • November 4, 2013
  • 2 replies
  • 13 views

andrew_patterso
Contributor
Forum|alt.badge.img+2
Hello FMERS,

 

We are planning to move from using batch files for error checking the daily FME workbench's log files for success or failure. 

 

Ideally we would like to write workbench parameters to the PostGreSQL database which then could be interrogated by another script

 

 

Does anyone have an example of a Python Shutdown script which  uses a PostGreSQL writer to add parameters such as FME_STATUS / data time into a PostGreSQL table.

 

 

Regards

 

Andrew

 

 

 

 

 

 

 

2 replies

david_r
Celebrity
  • November 4, 2013
Hi,

 

 

I haven't got an example, but I believe you could use the FMEUniversalWriter object of the fmeobjects API to write this data to PostGIS.

 

 

You'll find the documentation under <FME>/fmeobjects/python/apidoc/index.html

 

 

David

takashi
Influencer
  • November 5, 2013
Hi Andrew,

 

 

Another approach: If you create a second workspace having an SQLCreator transformer to write some data into the database, and link "SQL Statement" of the SQLCreator to a published parameter (named "SQL_STATEMENT" for example), you can create an SQL statement in Shutdown Script of the main workspace, pass the statement to the second workspace and run it via fmeobjects.FMEWorkspaceRunner object. Example (omit error handling): ----- import fmeobjects, time   sql = "\\"insert into myTable (status, tstamp) values ('%s', '%s')\\""  \\     % (FME_Status, time.strftime('%Y-%m-%d %H:%M:%S'))   ws = FME_MacroValues['FME_MF_DIR'] + 'second_workspace.fmw' params = {'SQL_STATEMENT' : sql}   runner = fmeobjects.FMEWorkspaceRunner() runner.runWithParameters(ws, params) runner = None -----

 

 

Takashi

Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings