Skip to main content
Solved

Need Fme Parameter Value/Fme Attribute Value Inside End Python Script


f.kemminje
Contributor
Forum|alt.badge.img+11

Hi Fme team,

After completion of fme script, i need to run sql query for the resultant destination table. So I am running sql thru end python script. And for this sql query I need one variable(fme published parameter or fme attribute)

from jest ran fme script. is there any way i can get value from fme published parameter into end python.

 

pls help.

Best answer by david_r

The Oracle Spatial Object writer does indeed have the "SQL to run after writer" setting:

You can reference published parameter inside it using $(PARAMETER_NAME) notation.

View original
Did this help you find an answer to your question?

8 replies

david_r
Celebrity
  • June 20, 2018

Which writer are you using?

Some writers have a setting for an SQL command to execute after the writer terminates, have you looked into that?


david_r
Celebrity
  • June 20, 2018

You can access published or private parameters in any Python code using the FME_MacroValues dictionary, e.g.

my_value = FME_MacroValues['MY_PUBLISHED_PARAMETER']

f.kemminje
Contributor
Forum|alt.badge.img+11
  • Author
  • Contributor
  • June 20, 2018

does it work inside shutdown Python script ?


f.kemminje
Contributor
Forum|alt.badge.img+11
  • Author
  • Contributor
  • June 20, 2018

@david_r

i use oracle spatial writer, And i am running shutdown python script.

can i access FME_MacroValues inside shutdown python?

 


david_r
Celebrity
  • June 20, 2018
david_r wrote:

You can access published or private parameters in any Python code using the FME_MacroValues dictionary, e.g.

my_value = FME_MacroValues['MY_PUBLISHED_PARAMETER']
It works in any Python code, so yes, it also works in the shutdown script.

david_r
Celebrity
  • Best Answer
  • June 20, 2018

The Oracle Spatial Object writer does indeed have the "SQL to run after writer" setting:

You can reference published parameter inside it using $(PARAMETER_NAME) notation.


f.kemminje
Contributor
Forum|alt.badge.img+11
  • Author
  • Contributor
  • June 20, 2018

@david_r

One quick question,

Calling python function inside shut down python script is not working for me?

for example

import fme 
import fmeobjects
make_a_sound()
def make_a_sound():
    print('quack')

Python Exception <NameError>: name 'make_a_sound' is not defined

Error executing string `import fme

 

 

its giving error


david_r
Celebrity
  • June 20, 2018
f.kemminje wrote:

@david_r

One quick question,

Calling python function inside shut down python script is not working for me?

for example

import fme 
import fmeobjects
make_a_sound()
def make_a_sound():
    print('quack')

Python Exception <NameError>: name 'make_a_sound' is not defined

Error executing string `import fme

 

 

its giving error

Python scripts (like most programming languages) are interpreted top-down, meaning that you must put the declaration of "make_a_sound" before you call it, e.g.

 

def make_a_sound():
    print('quack')

make_a_sound()

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