[DB-SIG] Python Script to run an Oralce select statement and return the value in HTML

Chris Curvey ccurvey at gmail.com
Thu Dec 21 12:32:01 CET 2006


I would start by adding

import cgitb; cgitb.enable()

at the top of your script.  Since "hello world" seems to work, and you can
get the script to run via the command line, there's probably something
different about the environment that IIS is using to execute your script.
(99% of the time, I find that it's a permissions problem.)

Hope this helps!



On 12/21/06, Boeing <mumatony-work at yahoo.com> wrote:
>
> Hi all;   [Vickie thanks for your sample command line script
> http://d0db.fnal.gov/d0db/query.py.txt]
>
> I need help [I'm not a developer] but I need a python script hosted on an
> windows 2003 server which will query a remote Oracle database [odbc
> connection established] either using Oracle 9.2 or cx_Oracle [both
> installed on the server] but return the value of the query in an html [web -
> URL] page, Username; password and database will be hard coded in the script
> on the server, script code will not be displayed to end user. Its a simple
> select statement returning a html page in rows. Eventually SSL is going to
> be implemented.
>
> I have been able to get the command line py script to work [Vickie
> White's]. But not calling it through IIS 6.  I get this error: CGI Error:
> The specified CGI application misbehaved by not returning a complete set of
> HTTP headers. But the python extension has been "Allowed" in IIS and a
> simple "Hello World" python script works. [[ i.e. not real URLs:
> http://metatest.web.mycompany.com/cgi-bin/helloworld.py]]
> Failing:  http://metatest.web.mycompany.com/cgi-bin/or3.py
>
> Sample for what I've gathered so far..
>
> #!/usr/bin/python
> print "Content-type: text/html\n\n";
> print "<html><body>";
> }
> }
> import     cx_Oracle
> }
> }
> def connect():
>
>     username = "typeUserNameHere" [hard coded]
>     password = "typePassHere" [hard coded]
>     database = "typeDataBaseHere" [hard coded]
> }
> Query:
> }
> }
> "select * from MIR_SYSTEM_VERSION"
>
> Any ideas or help [sample code] would be appreciated.
>
> _______________________________________________
> DB-SIG maillist  -  DB-SIG at python.org
> http://mail.python.org/mailman/listinfo/db-sig
>
>
>


-- 
I am often wrong, but I am never in doubt.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/db-sig/attachments/20061221/f166137e/attachment.htm 


More information about the DB-SIG mailing list