Hello, I have been trying to get the dynamic ZSQL method working for a long time and I think I am almost there. Here is what I am doing: My ZSQL method is named 'mysql' with one argument named 'params': select * from address where <dtml-in "params.keys()"> <dtml-var sequence-item> <dtml-var "params[_['sequence-item']]['op']"> '<dtml-var "params[_['sequence-item']]['val']">' <dtml-unless sequence-end> and </dtml-unless> </dtml-in> I am accessing it from a script named 'testsql': for row in context.mysql(params={'name':{'op':'=','val':'John Doe'}}): print row return printed When I run the script I get a message as follows: <r instance at 015C5760> That is all the message says. Now if I modify the script a little by removing the argument and changing it to: select * from address where <dtml-let params="{'name':{'op':'=','val':'John Doe'}}"> <dtml-in "params.keys()"> <dtml-var sequence-item> <dtml-var "params[_['sequence-item']]['op']"> '<dtml-var "params[_['sequence-item']]['val']">' <dtml-unless sequence-end> and </dtml-unless> </dtml-in> </dtml-let> I get the desired sql: select * from address where name = 'John Doe' Can anyone please help me here? I am a newbie and dealing with Zope. It has taken a lot of persistence to get to this point. I can't give up now. Thanks in advance. Kashif
Kashif Jabbar wrote at 2004-1-29 22:28 -0600:
... for row in context.mysql(params={'name':{'op':'=','val':'John Doe'}}): print row return printed
When I run the script I get a message as follows:
<r instance at 015C5760>
This is as it should look like: A Z SQL Method (performing a "select") returns a sequence of "r instances". Each such "r" ("row") instances represents one row of the result. An "r" instance has the fields of the result row as attributes. E.g. when you use "select a, b, c ..." then you can access the fields by "r.a", "r.b", "r.c", ... You can also access the fields by subscription "r[0]", "r[1]", ... -- Dieter
Dieter, Thank you very much. You provided the exact information I needed. Kashif Dieter Maurer wrote:
Kashif Jabbar wrote at 2004-1-29 22:28 -0600:
... for row in context.mysql(params={'name':{'op':'=','val':'John Doe'}}): print row return printed
When I run the script I get a message as follows:
<r instance at 015C5760>
This is as it should look like:
A Z SQL Method (performing a "select") returns a sequence of "r instances". Each such "r" ("row") instances represents one row of the result.
An "r" instance has the fields of the result row as attributes. E.g. when you use "select a, b, c ..." then you can access the fields by "r.a", "r.b", "r.c", ...
You can also access the fields by subscription "r[0]", "r[1]", ...
-- Kashif Jabbar Project Manager Strategic Systems International, Ltd. 1603 Orrington Ave, Suite 950 Evanston, IL 60201 847.424.2486 Direct 847.424.2480 Main 847.424.2481 Fax <http://www.ssidecisions.com/> ****** This communication and any files transmitted with it may contain information that is confidential, privileged and exempt from disclosure under applicable law. It is intended solely for the use of the individual or entity to which it is addressed. If you are not the intended recipient, you are hereby notified that any use, dissemination or copying of this communication is strictly prohibited. If you have received this communication in error, please notify the sender. Thank you for your co-operation.
participants (2)
-
Dieter Maurer -
Kashif Jabbar