ZSQMethods shipped with a Product
Hi, Is there a way to do FS based ZSQL methods in a Product ? Actually, my product (under development) uses direct MySQLdb.connections created/deleted for each method. This works but... 1/ It's not easy to be DBMS engine independant that way. 2/ Creating new DB connector for each Web transaction slows down the stuff. Thanks in advance -- Gilles
Gilles Lenfant wrote:
Hi,
Is there a way to do FS based ZSQL methods in a Product ? Actually, my product (under development) uses direct MySQLdb.connections created/deleted for each method. This works but...
1/ It's not easy to be DBMS engine independant that way.
2/ Creating new DB connector for each Web transaction slows down the stuff.
Why dont you use a regular database adaptor from within your Product? Given a eg. MySQL database adapter named 'the_mysql_da', I'd use something like this: import Acquisition from Products.ZSQLMethods.SQL import SQL # this class finds the DA via acquisition class MyZSQLMethods(Acquisition.Implicit): aZSQLMethod = SQL('aZSQLMethod', 'the title', 'the_mysql_DA', 'zsql_param1 zsql_param2', 'select xyz from my_relation ... ') class MyProduct(...): sql = MyZSQLMethods() def someMethod(self): rs = self.sql.aZSQLMethod( zsql_param1='foo', zsql_param2='bar') Take a look into lib/python/Products/ZSQLMethods/SQL.py and lib/python/Shared/DC/ZRDB/DA.py to find out more about the SQL class - peter.
Gilles Lenfant wrote:
Is there a way to do FS based ZSQL methods in a Product ? Actually, my product (under development) uses direct MySQLdb.connections created/deleted for each method. This works but...
1/ It's not easy to be DBMS engine independant that way.
2/ Creating new DB connector for each Web transaction slows down the stuff.
Perhaps this will help (it was created for precisely this problem): http://zope.org/Members/jccooper/extzsql Don't let the low version number scare you: it just hasn't needed any fixing or features. --jcc -- "My point and period will be throughly wrought, Or well or ill, as this day's battle's fought."
participants (3)
-
Gilles Lenfant -
J. Cameron Cooper -
Peter Sabaini