Peter,<br><br>I don&#39;t think I phrased my question very well. Also, I am coming from a Java background, so I am thinking about result sets, which may not be applicable to Python.<br><br>If I have a Z SQL Method query that returns multiple rows to a brains class, how do I <br>
<br>(1) reference the returned object that has all the rows<br>(2) reference a particular row in the returned object<br>(3) reference a particular piece of data in the returned object. <br><br>What is the returned object - list, dictionary, some special object with associated APIs?<br>
<br>Where is this documented? I can&#39;t seem to find it in the Zope 2 book.<br><br>Thanks!<br><br>Mark<br><br><div class="gmail_quote">On Tue, May 25, 2010 at 12:03 PM, Peter Sabaini <span dir="ltr">&lt;<a href="mailto:peter@sabaini.at">peter@sabaini.at</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div><div></div><div class="h5">On Mon, 2010-05-24 at 21:33 -0700, Mark Phillips wrote:<br>
&gt; I am reading the zope 2 book (relational database section) and it<br>
&gt; talks about binding classes by putting them in the Extensions<br>
&gt; directory and then associating them with a Z SQL Method. That seems to<br>
&gt; be rather straight forward, but where can I find some examples of<br>
&gt; accessing the values returned from the Z SQL Method in Python. For<br>
&gt; example,<br>
&gt;<br>
&gt; Z SQL Method<br>
&gt; select * from offense where gameID=&lt;some input value from a form&gt;<br>
&gt;<br>
&gt; This returns ~10 rows. Each row has columns playerID, PB, BB, SacBunt,<br>
&gt; HBP as well as other columns, all containing integer values.<br>
&gt;<br>
&gt; class GameStats<br>
&gt; &quot;&quot;&quot;Reads the database for the stats for every player in a game and<br>
&gt; calculates the stats&quot;&quot;&quot;<br>
&gt;<br>
&gt;     def AtBat(self, player_id):<br>
&gt;         &quot;&quot;&quot;Calculate the AB for a player. AB = PA - (BB + SacBunt +<br>
&gt; HBP - SF)&quot;&quot;&quot;<br>
&gt;         How do I get the columns PA, BB, etc for a particular playerID<br>
&gt; to calculate the BA from the result returned by the Z SQL method? Is<br>
&gt; there some documentation for how to access the results of the query<br>
&gt; within this class?<br>
<br>
</div></div>Individual columns should be accessible as attributes of the Brain<br>
object, eg. self.playerID etc. If there&#39;s a column PA, it should be<br>
named self.PA.<br>
<br>
Btw., usually when I&#39;m in doubt which attributes or methods are<br>
available for a given object, I just put a breakpoint at the location in<br>
question and poke at it with pdb, the Python debugger. See eg.<br>
<a href="http://wiki.zope.org/zope2/DebuggingWithPdb" target="_blank">http://wiki.zope.org/zope2/DebuggingWithPdb</a> , under &quot;breakpoint in the<br>
code&quot; how to invoke the debugger. See<br>
<a href="http://docs.python.org/library/pdb.html" target="_blank">http://docs.python.org/library/pdb.html</a> for pdb docs.<br>
<br>
hth,<br>
peter.<br>
<br>
&gt;<br>
&gt; Thanks!<br>
&gt;<br>
&gt; Mark<br>
&gt; _______________________________________________<br>
&gt; Zope-DB mailing list<br>
&gt; <a href="mailto:Zope-DB@zope.org">Zope-DB@zope.org</a><br>
&gt; <a href="https://mail.zope.org/mailman/listinfo/zope-db" target="_blank">https://mail.zope.org/mailman/listinfo/zope-db</a><br>
<br>
</blockquote></div><br>