Accessing ZSQL connection from external method
Howdy! I'm making heavy use of MySQLdb in my external methods. Now I just realized that ZSQL-connections are kept open permanently and it would save a lot of time if I wouldn't have to open a connection each time my external method is invoked but use the already existing ZSQL-connection instead. My question: How can I access a ZSQL-connection (ZMySQLDA) from an external method? --Ragnar P.S.: I benchmarked MySQLdb and found that opening a connection took 1.2ms on my systen whereas a very short request for authentication took only 1.1ms. So beeing able to use an existing connection would result in about 100% performance gain (at least at first glance).
Aha! I have it! Your external methods are given a pointer to self as the first arguement. You can use this to access any methods in the current folder (self is the current folder) So just call: self.MyZSQLMethod(arg1, arg2) where arg1 and arg2 are would be the arguments for the ZSQL Method. On Sun, Mar 26, 2000 at 02:36:19PM +0200, Ragnar Beer wrote:
Howdy!
I'm making heavy use of MySQLdb in my external methods. Now I just realized that ZSQL-connections are kept open permanently and it would save a lot of time if I wouldn't have to open a connection each time my external method is invoked but use the already existing ZSQL-connection instead. My question: How can I access a ZSQL-connection (ZMySQLDA) from an external method?
P.S.: I benchmarked MySQLdb and found that opening a connection took 1.2ms on my systen whereas a very short request for authentication took only 1.1ms. So beeing able to use an existing connection would result in about 100% performance gain (at least at first glance).
_______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
-- Under capitalism, man exploits man. Under communism, it's just the opposite. -- J.K. Galbraith
I had the same question, and found the answer in the code of the SQLSession product.. I haven't tried coding it myself yet, but its does exactly what you (and myself) are trying to do... --John Sutherland
-----Original Message----- From: zope-admin@zope.org [mailto:zope-admin@zope.org]On Behalf Of Ragnar Beer Sent: Sunday, March 26, 2000 7:36 AM To: zope@zope.org Subject: [Zope] Accessing ZSQL connection from external method
Howdy!
I'm making heavy use of MySQLdb in my external methods. Now I just realized that ZSQL-connections are kept open permanently and it would save a lot of time if I wouldn't have to open a connection each time my external method is invoked but use the already existing ZSQL-connection instead. My question: How can I access a ZSQL-connection (ZMySQLDA) from an external method?
--Ragnar
P.S.: I benchmarked MySQLdb and found that opening a connection took 1.2ms on my systen whereas a very short request for authentication took only 1.1ms. So beeing able to use an existing connection would result in about 100% performance gain (at least at first glance).
_______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
participants (3)
-
jiva@devware.com -
John Sutherland -
Ragnar Beer