Connection between python and mysql on mac os

Closed
raja - Feb 16, 2009 at 12:02 AM
rajasekhar1242 Posts 2 Registration date Thursday February 5, 2009 Status Member Last seen February 18, 2009 - Feb 18, 2009 at 11:27 PM
Hello,

i am trying to develop a database application. i am using python as front end and mysql as back end. But now i am getting some problem as "INTERNAL SERVER ERROR" while i am running my application on MAC OS x.

#!/usr/bin/python

import os
import cgi
from cgi import FieldStorage
from cStringIO import StringIO
from sys import exit


header = 'Content-type: text/html'

formhtml = """<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><html> <head>
<title> customer registrion form </title>
</head>
<center> <body bgcolor=gray>
<h1> Customer Registration Form </h1>
<form action="/cgi-bin/connectionven.py">
<table>
<tr> <td> customer name: </td>
<td><input type=text size=20 name=cusname> </td> </tr>
<tr> <td> city: </td>
<td> <input type=text size=20 name=city> </td> </tr>
<tr> <td> state: </td>
<td> <input type=text size=20 name=state> </td> </tr>
<center>
<tr> <td> <input type=submit name=submit> </td> </tr>
</center>
</table>
</form>
</body> </center>
</html> """

def showForm():
print header + formhtml


def process():
form = cgi.FieldStorage()
if form.has_key('cname'):
name = form['canme'].value
elif form.has_key['city']:
city = form['city'].value
elif form.has_key['state']:
state = form['state'].value

if form.has_key['action']:
try:
import MySQLdb
import _mysql_exceptions as DB_EXC
cxn = MySQLdb.connect(user='root')
cur = cxn.cursor()
cur.execute("insert into login.loginform values(%s,%s,%s)",(name,city,state))
cur.close()
cxn.commit()
cxn.close()
except ImportError , e:
return None
else:
showForm()

if __name__ == '__main__':
process()
Related:

1 response

rajasekhar1242 Posts 2 Registration date Thursday February 5, 2009 Status Member Last seen February 18, 2009
Feb 18, 2009 at 11:27 PM
hi every one,
i am getting problem when i am trying to run this application on safari. i am using web server which is built in mac os system.
i am getting the following message on my terminal when i am trying to get an error
rajasekhar:CGI-Executables venkata$ /usr/sbin/httpd -E connectionven.py
(13)Permission denied: httpd: could not open error log file connectionven.py.
(13)Permission denied: make_sock: could not bind to address [::]:80
(13)Permission denied: make_sock: could not bind to address 0.0.0.0:80
no listening sockets available, shutting down
Unable to open logs

pls give me a valuable reply.
0