Hello zope users, need your help: how to call sql method from the filesystem product? should i create this sql method through the web before, or is it possible to call sql directly from product code? Your help is very, very appreciated. Thanks in advance. Best regards, Ruslan mailto:alienoid@is.lg.ua
I usually add ZSQL Methods as attributes of my class, eg.: from Products.ZSQLMethods.SQL import SQL class myProduct(Acquisition.Implicit): flushLogData = SQL('flushLogData', 'Flush the access data to the RDBMS', 'database_connection', 'logData:string', '''execute flushLogData @logData=<dtml-sqlvar logData type=string> ''', ) The database connection is passed as a string; the SQL class has to able to find it via acqusition (hence I inherit from Acquisition.Implicit). For details see the Products.ZSQLMethods.SQL.SQL class cheers, peter. Ruslan Spivak wrote:
Hello zope users,
need your help: how to call sql method from the filesystem product? should i create this sql method through the web before, or is it possible to call sql directly from product code?
Your help is very, very appreciated. Thanks in advance.
Best regards, Ruslan mailto:alienoid@is.lg.ua
_______________________________________________ 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 )
need your help: how to call sql method from the filesystem product?
Call it by: result=self.queryTable() Then you've got len(result) or result.tuples() or result.dictionaries() or result[row][column] or even result.asRDB() to look at.
should i create this sql method through the web before, or is it possible to call sql directly from product code?
To create the method: from ZSQLMethods.SQL import SQL self._setObject('queryTable', SQL('queryTable', 'title', 'database connection', 'parameters if any', 'sql query')) Queries on relational databases are best going to zope-db@zope.org A -- Logical Progression Ltd, 3 Randolph Crescent, Edinburgh, EH3 7TH, UK Tel: +44 (0)131 466 9585 Web: http://www.logicalprogression.net/
participants (3)
-
Andrew Veitch -
peter sabaini -
Ruslan Spivak