[mod_python] mod_python and mysql - problem solved!

Michael C. Neel neel at mediapulse.com
Sun Jan 25 09:03:40 EST 2004


Grisha, given how often this hits the list, maybe the should be in the
FAQ/Docs.

Let's all have an uninstall php day!

Mike

> -----Original Message-----
> From: David Geller [mailto:dg at sponsera.com] 
> Sent: Saturday, January 24, 2004 5:15 PM
> To: Mod_python at modpython.org
> Subject: [mod_python] mod_python and mysql - problem solved!
> 
> 
> All:
> 
> Awhile ago I posted an issue under "mod_python and mysql - wierd 
> problem!' 1/8/2004
> 
> I was having similar problems to those described here:
> 
> 1. python program with sql queries worked fine in "console" mode
> 2. under mod_python, when I called "c.execute()", httpd would get a 
> "segmentation fault"  (this was apparent in the httpd error log)
> 3. sometimes, instead, I would get weird, inconsistant errors, like 
> Petros decribes.
> 
> Paul Querna actually hinted at what was wrong - but it took 
> me awhile to 
> find it (what was especially strange, and still unexplained, is why  
> things worked fine under mod_python on my redhat8 machine, but then 
> failed on the redhat9 server).
> 
> Explanation(?):
> 
>  In my httpd.conf I was loading two DSO modules: mod_python 
> and php4. It 
> turns out, when I removed the reference to php4, the 
> mod_python worked 
> perfectly. Now, why was this? Well, I went back to the php4 
> module, and 
> checked out "configure" - if you know anything about php, it 
> was being 
> configured with the "--with-mysql" flag, which tells it to use an 
> "internal" version of mysql libs. Apparently, this is fine - 
> as long as 
> *no other modules use mysql* (the php configure tells you this at the 
> end). If they do, you should specify the actual mysql library 
> directory. 
> Well, mod_python was basically another module using mysql. Duuuuh! 
> (well, not so obvious to me, really). When I specified the 
> actual mysql 
> library to php configure,  and recompiled and reinstalled the PHP, I 
> could have LoadModules for both php and mod_python and both 
> *appear* to 
> work.
> 
> Not completely sure why this is, but it seems to have solved 
> the problem.
> 
> David
> 
> 
> Petros Keshishian wrote:
> 
> >Ross:
> >
> >I had the same problem in mod_python with MySQL:
> >Namely the script was working from python shell, but
> >not in mod_python. I discovered that when I query only
> >one column  , e.g. 
> >C.execute('select id from cities where id=17;')
> >than it worked in mod_python as well, but when I try
> >for more that one column it dies. Unfortunatly I could
> >not find a solution and since my database is very
> >small I wrote a script that queries the database for
> >each column separately and then combines and returns
> >the result. This is not really a solution because it
> >does not address the problem and can slow down your
> >program significantly if your database is large.
> >
> >Try to see whether your script works when you query
> >only one column. I am very intersted in the solution
> >of this problem.
> >
> >-Petros
> >
> >
> >= = = Original message = = =
> >
> >Hello,
> >
> >I am working on porting some scripts over to
> >mod_python, but my scripts 
> >die when I attempt to execute a MySQL query.
> >
> >Here is a demonstration of the problem: 
> >http://localfeeds.com/near/display-rss.app
> >
> >In mozilla, it loads a blank page, on Safari, I get a
> >"page returned no 
> >data" error.
> >
> >The code in display-rss.py is:
> >-------------------------------
> >DB = "db"
> >USER = "user"
> >PASS = "password"
> >
> >import MySQLdb
> >
> >def index(req):
> >   
> >    DB_CONN = MySQLdb.connect(db=DB, user=USER,
> >passwd=PASS)
> >    C=DB_CONN.cursor()
> >    C.execute('select * from cities where id=17;')
> >    return "Something"
> >-------------------------------
> >
> >I have also tried using the code from : 
> >http://www.modpython.org/FAQ/faqw.py?req=all#3.3
> >
> >If I comment out the 'execute' statement, it works
> >fine, the page that 
> >comes back displays the word "Something:", as
> >expected.
> >
> >I am using  Apache/2.0.48
> >Python 2.3.3
> >mod_python 3.0.4
> >on FreeBSD 4.9
> >
> >My Apache configuration is:
> >AddHandler python-program .app
> >PythonHandler mod_python.publisher
> >PythonAutoReload On
> >PythonDebug On
> >
> >I suspect this will be related to the Apache/FreeBSD
> >threading can of 
> >worms... but I'm hoping there is another answer. If
> >anyone has a spare 
> >clue to offer, I'd really appreciate it.
> >
> >Thanks!,
> >
> >-Ross
> >_______________________________________________
> >Mod_python mailing list
> >Mod_python at modpython.org
> >http://mailman.modpython.org/mailman/listinfo/mod_python
> >
> >___________________________________________________________
> >Sent by ePrompter, the premier email notification
> >software.
> >Free download at http://www.ePrompter.com.
> >
> >__________________________________
> >Do you Yahoo!?
> >Yahoo! SiteBuilder - Free web site building tool. Try it!
> >http://webhosting.yahoo.com/ps/sb/
> >_______________________________________________
> >Mod_python mailing list
> >Mod_python at modpython.org
> >http://mailman.modpython.org/mailman/listinfo/mod_python
> >
> >
> >  
> >
> 
> -- 
> David Geller
> Sponsera, LLC
> dg at sponsera.com
> www.sponsera.com
> Phone: 703.532.6812
> Fax: 703.532.6058
> 
> 
> 
> _______________________________________________
> Mod_python mailing list
> Mod_python at modpython.org
> http://mailman.modpython.org/mailman/listinfo/mod_python
> 



More information about the Mod_python mailing list