I am having problems with a python program that I wrote. It is actually plpython3u. I am running the program as a Trigger from postgres. I am pretty sure the trigger part works. My test python program only does 2 things right now. It writes some junk to a file and then it tries to run a program that is on my C: drive (this is a Windows system, BTW). I am able to write to the file so the python program is being called correctly. As a test the program that I am trying to run is a BAT file that just does a COPY. The copy is never done so my code calling the external program is not working. Ultimately I want this to call a true Windows app (with a window to come up. Is this the best way to do this? Also, I got all the python stuff set up via a question here
I am using a Winows 7 machine with python32. Although it probably does not matter, I am using postgres 9.2 and I am running everything all of this via a SQL window from pgAdmin 1.16
Here is the code with the problem:
CREATE or replace FUNCTION scalesmyone (thename text)
RETURNS int
AS $$
a=5
f = open('C:\JUNK\frompython.txt','w')
f.write(thename)
f.close()
import os
os.system('"C:\Users\Jim\Desktop\BATfiles\run_addcust.bat"')
$$ LANGUAGE plpython3u;
Thanks,
Jim
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…