os.system behavior when calling SQLPlus with spooling

steve551979 at hotmail.com steve551979 at hotmail.com
Wed Jan 23 21:13:25 EST 2008


I'm trying to execute SQLPlus in python (on Redhat linux).

when calling sqlplus, i'm referencing an sql file which spools results
to a file, for e.g.:

spool "/tmp/qctemp2.out";
SELECT %s
FROM bug
WHERE BG_BUG_ID = %s;
spool off;
exit;


I'm noticing that when using:

os.system("sqlplus -S -L %s @/tmp/qctemp3.sql" % qc_login)

I'm able to execute fine, however, when I use:

f = popen4(("sqlplus -S -L %s @/tmp/qctemp3.sql" % qc_login)
print f.read()

I get problems where occasionally, sqlplus is run, but has problems
spooling results to a file, and python hangs on the print f.read()
statement.

I would prefer not to use os.system() since I want to analyze the
results.  Can anyone suggest how I should go about executing sqlplus
in this case?

Thanks for your help,
Steve

(note: please do not reply to my email address, only reply to this
group)



More information about the Python-list mailing list