[Zope3-Users] mysql connection
I am trying to connect to mysql. What is the preferred package to do that ? I am using zopeproject. I tried to add dependency to mysqldbda, but it fails. The 2nd edition of the book mentions mysql utility, but it is not installed by default it seems. Thanks, Roman [EMAIL PROTECTED] ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] MySQL connection timeout problem
On Mon, Sep 18, 2006 at 09:43:01AM -0700, Michael Bernstein wrote: > I am running into a problem that seems superficially similar to the one > described here: > http://mail.zope.org/pipermail/zope3-dev/2005-December/thread.html#17052 Michael and I finally managed to come up with a patch we think does all the right things: http://mail.zope.org/pipermail/checkins/2006-September/004078.html -- Brian Sutherland Metropolis - "it's the first movie with a robot. And she's a woman. And she's EVIL!!" ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] MySQL connection timeout problem
On Tue, Sep 19, 2006 at 02:14:39AM +0200, Brian Sutherland wrote: > On Mon, Sep 18, 2006 at 10:19:06AM -0700, Michael Bernstein wrote: > > Well, the problem requires an eight-hour timeout in order to manifest, > > so the only reason I am hitting it is because my prototype app is idle > > overnight. Does that help you reproduce it? > > Can you try this patch (barring typos;): For the record, this patch doesn't work in an interesting way! > Index: adapter.py > === > --- adapter.py(revision 70218) > +++ adapter.py(working copy) > @@ -77,3 +77,25 @@ > connection = ZopeDatabaseAdapter.__call__(self) > directlyProvides(connection, IMySQLZopeConnection) > return connection > + > +def isConnected(self): > +"""Check if we are connected to a database. > + > +Try to solve the dissapearing connection problem. For background, see > +http://mail.zope.org/pipermail/zope3-dev/2005-December/017052.html > +""" > +try: > +self._v_connection.ping() > +except MySQLdb.OperationalError: > +# not connected or ping did not restore MySQL connection > +if self._v_connection is not None: > +try: > +# this is a bare except because at this point > +# we are just trying to be nice closing the connection. > +# The situation is bad anyway. > +self._v_connection.close() > +except: > +pass > +self._v_connection = None > +return False > +return True -- Brian Sutherland Metropolis - "it's the first movie with a robot. And she's a woman. And she's EVIL!!" ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] MySQL connection timeout problem
On Mon, Sep 18, 2006 at 10:19:06AM -0700, Michael Bernstein wrote: > On Mon, 2006-09-18 at 19:04 +0200, Brian Sutherland wrote: > > On Mon, Sep 18, 2006 at 09:43:01AM -0700, Michael Bernstein wrote: > > > I am running into a problem that seems superficially similar to the one > > > described here: > > > http://mail.zope.org/pipermail/zope3-dev/2005-December/thread.html#17052 > > > > Looks the same to me. > > > > > Was a fix for the problem described in the above thread ever checked in? > > > > Doesn't look like it. Been meaning fix it as soon as I hit the problem > > again, so I can test it. > > Well, the problem requires an eight-hour timeout in order to manifest, > so the only reason I am hitting it is because my prototype app is idle > overnight. Does that help you reproduce it? Can you try this patch (barring typos;): Index: adapter.py === --- adapter.py (revision 70218) +++ adapter.py (working copy) @@ -77,3 +77,25 @@ connection = ZopeDatabaseAdapter.__call__(self) directlyProvides(connection, IMySQLZopeConnection) return connection + +def isConnected(self): +"""Check if we are connected to a database. + +Try to solve the dissapearing connection problem. For background, see +http://mail.zope.org/pipermail/zope3-dev/2005-December/017052.html +""" +try: +self._v_connection.ping() +except MySQLdb.OperationalError: +# not connected or ping did not restore MySQL connection +if self._v_connection is not None: +try: +# this is a bare except because at this point +# we are just trying to be nice closing the connection. +# The situation is bad anyway. +self._v_connection.close() +except: +pass +self._v_connection = None +return False +return True -- Brian Sutherland Metropolis - "it's the first movie with a robot. And she's a woman. And she's EVIL!!" ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] MySQL connection timeout problem
On Mon, 2006-09-18 at 19:04 +0200, Brian Sutherland wrote: > On Mon, Sep 18, 2006 at 09:43:01AM -0700, Michael Bernstein wrote: > > I am running into a problem that seems superficially similar to the one > > described here: > > http://mail.zope.org/pipermail/zope3-dev/2005-December/thread.html#17052 > > Looks the same to me. > > > Was a fix for the problem described in the above thread ever checked in? > > Doesn't look like it. Been meaning fix it as soon as I hit the problem > again, so I can test it. Well, the problem requires an eight-hour timeout in order to manifest, so the only reason I am hitting it is because my prototype app is idle overnight. Does that help you reproduce it? - Michael ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
[Zope3-Users] MySQL connection timeout problem
I am running into a problem that seems superficially similar to the one described here: http://mail.zope.org/pipermail/zope3-dev/2005-December/thread.html#17052 Was a fix for the problem described in the above thread ever checked in? Here is my traceback (a Zope restart also makes this go away): Traceback (most recent call last): File "/home2/webmaven2/Zope-3.2.1.source/build/lib.linux-i686-2.4/transaction/_transaction.py", line 507, in abort rm.abort(self) File "/home2/webmaven2/Zope-3.2.1.source/build/lib.linux-i686-2.4/transaction/_transaction.py", line 634, in abort self._datamanager.abort(transaction) File "/home2/webmaven2/Zope-3.2.1.source/build/lib.linux-i686-2.4/zope/app/rdb/__init__.py", line 445, in abort self._dbconn.rollback() File "/home2/webmaven2/Zope-3.2.1.source/build/lib.linux-i686-2.4/zope/app/rdb/__init__.py", line 391, in rollback self.conn.rollback() OperationalError: (2006, 'MySQL server has gone away') Traceback (most recent call last): File "/usr/local/lib/python2.4/threading.py", line 422, in run self.__target(*self.__args, **self.__kwargs) File "/home2/webmaven2/Zope-3.2.1.source/build/lib.linux-i686-2.4/twisted/python/threadpool.py", line 149, in _worker context.call(ctx, function, *args, **kwargs) File "/home2/webmaven2/Zope-3.2.1.source/build/lib.linux-i686-2.4/twisted/python/context.py", line 59, in callWithContext return self.currentContext().callWithContext(ctx, func, *args, **kw) File "/home2/webmaven2/Zope-3.2.1.source/build/lib.linux-i686-2.4/twisted/python/context.py", line 37, in callWithContext return func(*args,**kw) --- --- File "/home2/webmaven2/Zope-3.2.1.source/build/lib.linux-i686-2.4/twisted/web2/wsgi.py", line 139, in run result = self.application(self.environment, self.startWSGIResponse) File "/home2/webmaven2/Zope-3.2.1.source/build/lib.linux-i686-2.4/zope/app/wsgi/__init__.py", line 54, in __call__ request = publish(request, handle_errors=handle_errors) File "/home2/webmaven2/Zope-3.2.1.source/build/lib.linux-i686-2.4/zope/publisher/publish.py", line 146, in publish publication.handleException( File "/home2/webmaven2/Zope-3.2.1.source/build/lib.linux-i686-2.4/zope/app/publication/zopepublication.py", line 243, in handleException transaction.abort() File "/home2/webmaven2/Zope-3.2.1.source/build/lib.linux-i686-2.4/transaction/_manager.py", line 107, in abort return self.get().abort(sub, deprecation_wng=False) File "/home2/webmaven2/Zope-3.2.1.source/build/lib.linux-i686-2.4/transaction/_transaction.py", line 507, in abort rm.abort(self) File "/home2/webmaven2/Zope-3.2.1.source/build/lib.linux-i686-2.4/transaction/_transaction.py", line 634, in abort self._datamanager.abort(transaction) File "/home2/webmaven2/Zope-3.2.1.source/build/lib.linux-i686-2.4/zope/app/rdb/__init__.py", line 445, in abort self._dbconn.rollback() File "/home2/webmaven2/Zope-3.2.1.source/build/lib.linux-i686-2.4/zope/app/rdb/__init__.py", line 391, in rollback self.conn.rollback() _mysql_exceptions.OperationalError: (2006, 'MySQL server has gone away') ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] MySQL connection timeout problem
On Mon, Sep 18, 2006 at 09:43:01AM -0700, Michael Bernstein wrote: > I am running into a problem that seems superficially similar to the one > described here: > http://mail.zope.org/pipermail/zope3-dev/2005-December/thread.html#17052 Looks the same to me. > Was a fix for the problem described in the above thread ever checked in? Doesn't look like it. Been meaning fix it as soon as I hit the problem again, so I can test it. -- Brian Sutherland Metropolis - "it's the first movie with a robot. And she's a woman. And she's EVIL!!" ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
[Zope3-Users] MySQL Connection Closed Errors
What is the best way to manage MySQL connections? We’re using the mysqldba and frequently get the following errors when calling queryForResults: File "/home/djohnson/Zope-3.2.0/build/lib.linux-i686-2.4/zope/app/rdb/__init__.py", line 408, in queryForResults raise DatabaseException(str(error)) DatabaseException: Shouldn't load state for 0x01b3 when the connection is closed We’re implementing in the following fashion: self.connection = zapi.getUtility(IZopeDatabaseAdapter, name) query = “select * from contacts” results = queryForResults(self.connection,query) It’s a local database on a machine with very little load, so connection issues should not be a regular problem. -- David Johnson ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users