从Oracle运行.py(plsql) [英] Run .py from oracle (plsql)

查看:109
本文介绍了从Oracle运行.py(plsql)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要一种从oracle(pl/sql)运行python(.py)脚本的解决方案.有什么解决办法吗?

I need a solution to run python (.py) scripts from oracle (pl/sql). Is there any solution?

例如:我有一个python脚本可以发送gmail并从Oracle数据库创建Excel电子表格.但是我必须使用Oracle来称呼它,而且还必须使用Oracle的参数.

For example: I have a python script to send gmail and create Excel spreadsheet from Oracle database. But I have to call this with Oracle, and I also have to use parameters from Oracle.

推荐答案

DBMS_SCHEDULER可能有用.

DBMS_SCHEDULER might be of use.

首先创建一个外壳脚本,该外壳脚本是Python的包装.

First create a shell script that is a wrapper for your Python.

然后创建作业.

begin
dbms_scheduler.create_program
(
program_name => 'PYEXCEL',
program_type => 'EXECUTABLE',
program_action => '/the_path/the_py_script_wrapper.ks',
enabled => TRUE,
comments => 'Call Python stuff'
);
end;
/

请注意,可以为作业配置参数,以防脚本需要这些参数.

Note, jobs can be configured with parameters in case your script needs these.

然后运行:

BEGIN
  DBMS_SCHEDULER.RUN_JOB(
    JOB_NAME            => 'PYEXCEL',
    USE_CURRENT_SESSION => FALSE);
END;
/

这是我认为的最纯正"的PLSQL唯一方式.

This is the 'purest' PLSQL only way I think.

这篇关于从Oracle运行.py(plsql)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆