[mod_python] MySQL

thanos at 0x01.com thanos at 0x01.com
Thu Feb 7 15:32:57 EST 2002


Has any one had MySQL expiriences ? 

When using cgi's we have exprienced no problems, but the following script 
will often break.

from mod_python import apache

def handler(req):
        import MySQLdb
        req.send_http_header()
        req.write("importd MySQLdb hello world")
        return apache.OK



I think on its first time the httpd execurtes this handler without any outward problems, but on the second time round:

Mod_python error: "PythonHandler testmysql"

Traceback (most recent call last):

  File "/usr/local/lib/python2.1/site-packages/mod_python/apache.py", line 181, in Dispatch
    module = import_module(module_name, _req)

  File "/usr/local/lib/python2.1/site-packages/mod_python/apache.py", line 356, in import_module
    if os.path.exists(filepath[:-1]) :

  File "/usr/local/lib/python2.1/posixpath.py", line 171, in exists
    st = os.stat(path)

OSError: [Errno 2] No such file or directory: '/usr/home/thanos/public_html/pso/tests/testmsql/testmysql.p'



You can try it out at:

http://www.0x01.com/~thanos/pso/tests/testmsql/mptest.py

Moving the import statement outside the handler will make the handle break every time. I guess this is some sort of clue. 

Any help would be great

thanks

thanos.








More information about the Mod_python mailing list