|
Noam Hoffer
noamhooper at hotmail.com
Tue Dec 4 20:03:04 EST 2001
Hello,
I didn't succed in using MySQLdb module from mod_python. I get the following error:
Mod_python error: "PythonHandler mptest"
Traceback (most recent call last):
File "C:\Python21\Lib\mod_python\apache.py", line 181, in Dispatch
module = import_module(module_name, _req)
File "C:\Python21\Lib\mod_python\apache.py", line 338, in import_module
module = imp.load_module(mname, f, p, d)
File "C:\Program Files\Apache Group\Apache\htdocs\python\test\mptest.py", line 2, in ?
import MySQLdb
File "C:\Python21\MySQLdb\__init__.py", line 27, in ?
import _mysql
ImportError: _mysql: init failed
when using it from the interpreter it works file.
here is my script:
from mod_python import apacheimport MySQLdb
def _db_login(relogin = 0): """Login to the database """
global DB_CONN
if relogin: DB_CONN = MySQLdb.connect(db="test") return DB_CONN else: try: d = DB_CONN return d
except NameError: DB_CONN = MySQLdb.connect(db="test") return DB_CONN
def handler(req): req.content_type = "text/plain" req.send_http_header() req.write("Hello World!") conn = _db_login() cur = conn.cursor() cur.execute("select * from stam") req.write(cur.fetchall())
return apache.OK
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.modpython.org/pipermail/mod_python/attachments/20011204/8221f032/attachment-0003.htm
|