[Tutor] Whats wrong with this code..??
shobhan
schalla@vasoftware.com
Fri Nov 15 09:40:09 2002
--------------090409000600010301040002
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit
Im trying to execute the following python code in a browser:
#!/usr/bin/python
import os
import sys
import commands
import string
import urllib
sys.path.append('/mainscripts/etc/scripts') #the folder for local
sys.path.append('/mainscripts/scripts/python/common') # folder for
logger_conf
import local
import logger_conf
import sql_utils
import re
dbapi = __import__('cx_Oracle')
dbh = dbapi.connect(logger_conf.db_dsn)
dbc = dbh.cursor()
print "Content-Type: text/html\n\n"
print "<html><head><title>Testing script</title></head>"
print "<body>"
print "DSN :" + logger_conf.db_dsn
print "<p>Im alive</p>"
dbc.execute("select user_id,user_name,email from users")
rows = dbc.fetchall()
print "USERID :" + rows[0]
print "USER_NAME :" + rows[1]
print "EMAIL :" + rows[2]
print "</body></html>"
------------------------------------------
The problem with the script is if i comment the line "dbh =
dbapi.connect(logger_conf.db_dsn)" its working fine , i.e its printing
the DSN correctly, but if this line is uncommented its displaying
"Internal Server Error". When i check the apache log it gives the
following error:
Traceback (most recent call last):
File "/sourceforge/sfee/www/search/cc_scm_content.py", line 15, in ?
dbh = dbapi.connect(logger_conf.db_dsn)
cx_Oracle.DatabaseError: Error while trying to retrieve text for error
ORA-12154
[Fri Nov 15 08:58:37 2002] [error] [client 11.1.30.9] Premature end of
script headers: /sourceforge/sfee/www/search/cc_scm_content.py
Can anyone tell whats wrong with this code??
Thanks
Schalla
--------------090409000600010301040002
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: 7bit
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title></title>
</head>
<body>
<font face="Times New Roman, Times, serif"><font
face="Helvetica, Arial, sans-serif" size="-1">Im trying to execute the following
python code in a browser:</font><br>
<br>
<font size="-1" face="Helvetica, Arial, sans-serif">#!/usr/bin/python<br>
import os<br>
import sys<br>
import commands<br>
import string<br>
import urllib<br>
sys.path.append('/mainscripts/etc/scripts') #the folder for local<br>
sys.path.append('/mainscripts/scripts/python/common') # folder for logger_conf<br>
import local<br>
import logger_conf<br>
import sql_utils<br>
import re<br>
<br>
dbapi = __import__('cx_Oracle')<br>
dbh = dbapi.connect(logger_conf.db_dsn)<br>
dbc = dbh.cursor()<br>
<br>
print "Content-Type: text/html\n\n"<br>
print "<html><head><title>Testing script</title></head>"<br>
print "<body>"<br>
print "DSN :" + logger_conf.db_dsn<br>
print "<p>Im alive</p>"<br>
<br>
dbc.execute("select user_id,user_name,email from users")<br>
rows = dbc.fetchall()<br>
print "USERID :" + rows[0]<br>
</font></font><font face="Times New Roman, Times, serif"><font size="-1"
face="Helvetica, Arial, sans-serif">print "USER_NAME :" + rows[1]</font></font><br>
<font face="Times New Roman, Times, serif"><font size="-1"
face="Helvetica, Arial, sans-serif">print "EMAIL :" + rows[2]</font></font><br>
<font face="Times New Roman, Times, serif"><font size="-1"
face="Helvetica, Arial, sans-serif">print "</body></html>"<br>
<br>
------------------------------------------<br>
The problem with the script is if i comment the line </font></font><font
face="Times New Roman, Times, serif"><font size="-1"
face="Helvetica, Arial, sans-serif">"dbh = dbapi.connect(logger_conf.db_dsn)</font></font><font
face="Times New Roman, Times, serif"><font size="-1"
face="Helvetica, Arial, sans-serif">" its working fine , i.e its printing
the DSN correctly, but if this line is uncommented its displaying "Internal
Server Error". When i check the apache log it gives the following error:<br>
<br>
</font></font><font size="-1" face="Helvetica, Arial, sans-serif"
color="#cc6600">Traceback (most recent call last):<br>
File "/sourceforge/sfee/www/search/cc_scm_content.py", line 15, in ?<br>
dbh = dbapi.connect(logger_conf.db_dsn)<br>
cx_Oracle.DatabaseError: Error while trying to retrieve text for error ORA-12154<br>
<br>
[Fri Nov 15 08:58:37 2002] [error] [client 11.1.30.9] Premature end of script
headers: /sourceforge/sfee/www/search/cc_scm_content.py</font><br>
<br>
<font face="Helvetica, Arial, sans-serif" size="-1">Can anyone tell whats
wrong with this code??<br>
<br>
Thanks<br>
Schalla</font><br>
<br>
<br>
</body>
</html>
--------------090409000600010301040002--