[Zope] Passing Z-SQL Method Result to Pythin Script
AM
list_subscriber@neurobs.com
Fri, 14 Feb 2003 14:52:30 -0800
You can use the Zsql method. Just call it as you would any other function:
result = context.<zsql_method_name>
result will be a cursor object -
http://www.python.org/topics/database/DatabaseAPI-2.0.html#cursor
which you can then use to extract results using fetchone or fetchall or
fetchmany
data = result.fetchall()
This will give you a list of dictionaries so to extract content from the
first record in the recordset returned:
data[0].content
hth
AM
Mico Siahaan wrote:
>3:52 PM 2/14/2003
>
>I stored articles data in MySQL. The fields of articles tables are:
>title, content, and their date of submitted. Suppose I want to show only
>some of the content of the articles (about only 50 words shown), how do
>I do it in Zope? I thought I could use Z-SQL Method to get the full
>content from MySQL then processed Z-SQL result with python script. But I
>failed. I did not know how to pass the Z-SQL Method result to python
>script. Can anybody give me an example how to do it?
>
>Thanks.
>
>
>
--
==================================================================
Aseem Mohanty
Neurobehavioral Systems Inc, 828 San Pablo Ave, Albany, CA 94706
(R) 510 7696011 (M) 510 3014871 (O) 510 5279231
==================================================================
"I saw `cout' being shifted "Hello world" times to the left and
stopped right there!!" -- Steve Gonedes
==================================================================