cancel
Showing results for 
Search instead for 
Did you mean: 

SAP BODS 4.2 SP 8 : how to execute a python script in a script

SAP BODS 4.2 SP 8 : how to execute a python script in a script

could anyone share some sample of how to execute .py python script within a bods script ?

need to execute a python script that inturn runs HIVE QL scripts for data load into HIVE.

Responses with detailed explanation appreciated since i am new to DS

0 Kudos

Hi Srihari,

I have similar question, are you able to achieve this please let me know

Thanks

Madhu

Accepted Solutions (0)

Answers (4)

Answers (4)

jmuiruri
Product and Topic Expert
Product and Topic Expert
0 Kudos

Greetings mobireddy,

Please see the solution provided in the Knowledge article below

Best Regards,

Joseph

Thanks Joseph,

I am able to achieve this and below is the syntax to execute python Script from BODS Script

exec('ksh', '-c "sudo python3 path of the python script/file.py"', 😎

The Sudo - may or may not be required

Thanks

Madhu

0 Kudos

If DS has built in Python, does that mean Python is already installed on the job server or would I need to install it myself - if so, would it need to be a specific Python version so I don't interfere with the existing UDT version?

If indeed it is possible, I would prefer to call Python via DS script and not through the UDT.

0 Kudos

Hi, srihari.

You can use User_Defined Transform in Data Services for this purpose.

You can execute your python script within BODS or use classes and functions from your custom python module in the following way:

  1. Put your script to the file server at an accessible location.
  2. Insert User_Defined Transform in BODS Job and import your python script using "imp" module and use classes and functions from your custom script.
import imp
myscript = imp.load_source('myscript', '//job_server/lib_path/myscript.py')
myscript.myFunction()
Rishabh_Awasthi
Active Participant
0 Kudos

Use exec function to call the python script:

exec('E:\Python34\python.exe', '<ScriptLocation>\HIVEScript.py , '8');

The Python exe file path is relative to BODS server.

Regards,
Rishabh