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

Boeing mumatony-work at yahoo.com
Thu Dec 21 10:33:38 CET 2006


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. 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/db-sig/attachments/20061221/1ce4dc72/attachment.html 


More information about the DB-SIG mailing list