I'm trying to call an external Python script file from a PostgreSQL function written in PL/Python.
My intuition drove me to code something like this :
CREATE OR REPLACE FUNCTION foo() Returns boolean AS
$$
import subprocess
cmd = "C:\\Python27\\python.exe"
file_to_execute = "C:\\Users\\manager_gui.py"
subprocess.check_call([cmd, file_to_execute])
$$
LANGUAGE 'plpython3u' VOLATILE;
But when I execute SELECT foo()
it returns me this error message :
"Command '['C:\\Python27\\python.exe', 'C:\\Users\\manager_gui.py']' returned non-zero exit status 2"
I Googled it and obviously it deals with an execution permission issue. But I'm not really sure...
So let me ask if it is really possible to do what I want to do and if I use the good method?
And if the answer is yes, how can I manage this execution permission issue between my PosgreSQL user and the owner of the script file?
Thank you in advance,
Martin