Question Concerning Z SQL Method and Class Bindings

Mark Phillips <[email protected]> Mon, 24 May 2010 21:33:10 -0700
Newsgroups gmane.comp.web.zope.database
Message-ID <[email protected]>
--===============1086853439019148224==
Content-Type: multipart/alternative; boundary=0016e64c2dcea5a722048763a756

--0016e64c2dcea5a722048763a756
Content-Type: text/plain; charset=ISO-8859-1

I am reading the zope 2 book (relational database section) and it talks
about binding classes by putting them in the Extensions directory and then
associating them with a Z SQL Method. That seems to be rather straight
forward, but where can I find some examples of accessing the values returned
from the Z SQL Method in Python. For example,

Z SQL Method
select * from offense where gameID=<some input value from a form>

This returns ~10 rows. Each row has columns playerID, PB, BB, SacBunt, HBP
as well as other columns, all containing integer values.

class GameStats
"""Reads the database for the stats for every player in a game and
calculates the stats"""

    def AtBat(self, player_id):
        """Calculate the AB for a player. AB = PA - (BB + SacBunt + HBP -
SF)"""
        How do I get the columns PA, BB, etc for a particular playerID to
calculate the BA from the result returned by the Z SQL method? Is there some
documentation for how to access the results of the query within this class?

Thanks!

Mark

--0016e64c2dcea5a722048763a756
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

I am reading the zope 2 book (relational database section) and it talks
about binding classes by putting them in the Extensions directory and
then associating them with a Z SQL Method. That seems to be rather
straight forward, but where can I find some examples of accessing the
values returned from the Z SQL Method in Python. For example,<br>
<br>Z SQL Method<br>select * from offense where gameID=3D&lt;some input val=
ue from a form&gt;<br><br>This returns ~10 rows. Each row has columns playe=
rID, PB, BB, SacBunt, HBP as well as other columns, all containing integer =
values.<br>
<br>class GameStats<br>&quot;&quot;&quot;Reads the database for the stats f=
or every player in a game and calculates the stats&quot;&quot;&quot;<br>
<br>=A0=A0=A0 def AtBat(self, player_id):<br>=A0=A0=A0 =A0=A0=A0 &quot;&quo=
t;&quot;Calculate the AB for a player. AB =3D PA - (BB + SacBunt + HBP - SF=
)&quot;&quot;&quot;<br>=A0=A0=A0=A0=A0=A0=A0
How do I get the columns PA, BB, etc for a particular playerID to
calculate the BA from the result returned by the Z SQL method? Is there som=
e documentation for how to access the results of the query within this clas=
s?<br>
=A0=A0=A0 =A0=A0 <br>Thanks!<br><br>Mark<br>

--0016e64c2dcea5a722048763a756--

--===============1086853439019148224==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
Zope-DB mailing list
[email protected]
https://mail.zope.org/mailman/listinfo/zope-db

--===============1086853439019148224==--