[Zope] Calling SQL from Python products
Dario Lopez-Kästen
dario at ita.chalmers.se
Tue Sep 21 12:15:00 EDT 2004
Johan Carlsson wrote:
> Here an example of a really fast way of executing SQL questions in a
> Python Product:
>
> from Shared.DC.ZRDB.Results import Results
> from Shared.DC.ZRDB import RDB
>
> class MyProduct(SimpleItem):
>
> def __init__(self, database_name='MySQL_database_connection'):
> self.database_name=database_name
>
> def getDB(self):
> return getattr(self, self.database_name, None)
> def queryDB(self, query):
> """query is a text with your SQL quetion, note not ZSQLMethod
> code!"""
hm... interesting... there is a way to use ZSQL methods with this. It is
possible to render the ZSQL into a string, passing a parameter (which at
the moment eludes me - check the source) to it.
this string could then be passed to the queryDB method...
/dario
--
-- -------------------------------------------------------------------
Dario Lopez-Kästen, IT Systems & Services Chalmers University of Tech.
More information about the Zope
mailing list