I have a code in Oracle which is optimized and create weekly data. The problem is I also want my Oracle code trigger Python to run and create data in Python and save. Is there any possibility to execute my Python code automatically?
-
1If you're on linux `cron` job would be good. – Vineeth Sai Nov 01 '18 at 06:30
-
no, I'm not :( do you know any solution to handle it in Windows – usr324523 Nov 01 '18 at 06:41
-
On windows the Task scheduler can be used in order to rerun tasks https://stackoverflow.com/questions/4437701/run-a-batch-file-with-windows-task-scheduler – quant Nov 01 '18 at 07:16
-
possible duplicate of https://stackoverflow.com/questions/48085250/how-to-schedule-a-daily-task-to-run-a-batch-file – quant Nov 01 '18 at 07:21
-
*"trigger Python to run and create data in Python and save"*. When will the python code run? Where will the python code save the data it creates? – APC Nov 01 '18 at 08:22
-
i want my data to be created when my automatic oracle code ended. so after that python will have execution point which it will start running and save the data as excel. – usr324523 Nov 01 '18 at 10:46
4 Answers
You can trigger python script by setting up a cron job.
You can do this using python and crontab: see this documentation https://pypi.org/project/python-crontab/

- 297
- 1
- 3
- 12
you can use crons jon, task schedule to run the script in particular time. If you want to run the script as service you can use celery and crontab module.

- 56
- 5
-
does it help me to run my code without running it? my main point is to execute my Oracle code to run python automatically. – usr324523 Nov 01 '18 at 06:50
Another solution is to leave Python running, and let a Continuous Query Notification (CQN) callback from the data change invoke a python method. Or use Oracle Advanced Queues for the same. Examples are in https://github.com/oracle/python-cx_Oracle/tree/master/samples
You could also use the DB's UTL_HTTP functionality to invoke a web service that runs python.

- 9,449
- 3
- 24
- 48
i use windows task planner with a .bat script to run my python code everyday.

- 326
- 1
- 3
- 16