[Zope] Connection to MySQL in zope product

Marco Bizzarri m.bizzarri at icube.it
Mon Mar 14 04:22:46 EST 2005


bahriesz at yahoo.com wrote:
> Hi,
> 
> I plan to develop a product that make use of external
> database (MySQL). I tried to get some reference on
> this in internet, but to no avail. How can i do this?.
> 
> I understand that with python script or dtml we need
> to create database connection object, and zsql method.
> But how do we do it from product class?. 
> 
> If i can get some point of reference from the net, it
> would be good.
> 
> Thanks.
> 
> 
> 		

What you could do inside your product is:

from Products.ZSQLMethods.SQL import SQL

class MyProduct(SimpleItem):

	a_query = SQL('aQuery', 'a query', 'a_db_connection', 'param1'
	"""
		SELECT * FROM data WHERE <dtml-sqltest param1 op="eq" type="string">
	""")


	...

	def my_method(self):

		result = self.a_query(param1='a param1')
		....

Regards
Marco


More information about the Zope mailing list