[Zope-DB] getting results from a ZSQL method in a python script

Wade Leftwich wade@okaynetwork.com
Tue, 11 Dec 2001 15:40:34 -0500


# ZSQL method getPeople
select * from People
<dtml-sqlgroup where>
<dtml-sqltest fname type=string op=eq optional>
<dtml-and>
<dtml-sqltest lname type=string op=eq optional>
</dtml-group>

# Script
queryargs = {'fname':'Antoine}  # by not specifying lname we will get 
                                            # Antoine Muller, Anton Smith,
                                            # Antoine Jones, etc.
recset = container.getPeople(queryargs)
cols = recset.names()
for col in cols:
    print col,
print
for rec in recset:
    for col in cols:
        print rec[col],
    print

return printed

####

hth

Wade Leftwich
Ithaca, NY


On Tuesday 11 December 2001 12:01, zope-db-request@zope.org wrote:
> Date: Tue, 11 Dec 2001 13:18:17 +0100
> From: Antoine Muller <Antoine.Muller@unine.ch>
> Reply-To: Antoine.Muller@unine.ch
> To: zope-db@zope.org
> Subject: [Zope-DB] getting results from a ZSQL method in a python script
>
> Hello list,
> I need help on the following subject, I have been able to call a ZSQL
> method from a Python script, I have probably been able to transmit it
> parameters but I have no idea how to get the results.
> - What is the representation of a ZSQL method results?
> - How to put it in a python variable?
> - How to access this variable?