Gmail Calendar Documents Reader Web more »
Recently Visited Groups | Help | Sign in
Google Groups Home
HowTo: Patch mysqldb and sqlobject so database doesn't "go away" all the time
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  1 message - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Sean McBride  
View profile  
(1 user)  More options Jul 26 2006, 9:46 pm
From: "Sean McBride" <sean...@gmail.com>
Date: Wed, 26 Jul 2006 18:46:56 -0700
Local: Wed, Jul 26 2006 9:46 pm
Subject: HowTo: Patch mysqldb and sqlobject so database doesn't "go away" all the time
We were continually having a problem on our production test server
where we would get random 500 errors. The underlying error was that
"MySQL server has gone away", and we searched around forever online
trying to find a solution. Finally we did. I figured that I'd post here
so that others could benefit.

Basically, the Python mysql library is missing an interface with the C
library's MYSQL_OPT_RECONNECT flag which instructs the client to
reconnect with the mysql server if the connection is lost or refused
for some reason (which I guess can happen frequently on a busy server.)
Thus, connections get dropped and you get 500 errors. Luckily, there's
a patch that a user submitted to the mysqldb sourceforge project.

Here's what to do:

1. First, go and download the patch from this location:
http://sourceforge.net/tracker/index.php?func=detail&aid=1483074&grou...

2. Get the correct version of MySQLdb to apply the patch to:
svn co
https://svn.sourceforge.net/svnroot/mysql-python/tags/MySQLdb-1.2.1_p2
mysqldb-patched

3. Go into the mysqldb-patched/MySQLdb/ directory and apply the patch
to the install:
patch < mysql-patch

4. Build the patched library
python setup.py build
(If you have errors here, make sure you have all the dev packages you
need. Likely missing candidates are python-dev and
libmysqlclient15-dev)

5. Install the patched library
python setup.py install

6. Remove the bogus sets.py, sets.pyc, sets.pyo files.
(For some reason, this version of mysqldb has files that override the
default sets library. Just delete them all from your python
site-packages/MySQLdb/ directory.)

7. Try importing MySQLdb
(It should work now.)

8. Edit your SQLObject file:
(In your SQLObject folder in site-packages, edit the
mysql/mysqlconnection.py file and  add reconnect=1 to the arguments
passed to the self.module.connect function in
MySQLConnection.makeConnection.)

Now you should have no more "mysql has gone away" errors. (If that was
your problem.)

Anybody else ever have to do this?


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2009 Google