Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
320 views
Welcome To Ask or Share your Answers For Others

1 Answer

I changed to the the subprocess but I still have a problem with the Windows 7 Folders having read-only permissions. I asked the question here


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...