[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[no subject]
- <!--x-content-type: text/plain --> "http://www.w3.org/TR/html4/loose.dtd">
- <!--x-date: Tue Jan 25 14:49:01 2005 -->
- <!--x-from-r13: psbjyre ng bhgcbfgfragvary.pbz (Quevfgbcure Tbjyre) -->
- <!--x-message-id: [email protected] -->
- <!--x-subject: [ale] Pyhon syntax -->
- <li><em>date</em>: Tue Jan 25 14:49:01 2005</li>
- <li><em>from</em>: cfowler at outpostsentinel.com (Christopher Fowler)</li>
- <li><em>subject</em>: [ale] Pyhon syntax</li>
I'm playing with MySQL DB and am executing some queries.
>>> import MySQLdb
>>> db=MySQLdb.connect(host="127.0.0.1", user="cms", passwd="cms",
db="AC_OUTPOST");
>>> c = db.cursor();
>>> c.execute("SELECT * FROM ens;");
5L
>>>
What I am wanting to do is a while loop to fetch each row. I assume I
use the fetchone method of the DB API.
>>> while row=c.fetchone():
File "<stdin>", line 1
while row=c.fetchone():
^
SyntaxError: invalid syntax
>>>
Everytime I see a while loop in examples I see a "while 1:" Then to
get out of the loop I see a break. What is the proper syntax?
Thanks,
Chris
</pre>
<!--X-Body-of-Message-End-->
<!--X-MsgBody-End-->
<!--X-Follow-Ups-->
<hr>
<ul><li><strong>Follow-Ups</strong>:
<ul>
<li><strong><a name="01068" href="msg01068.html">[ale] Pyhon syntax</a></strong>
<ul><li><em>From:</em> cfowler at outpostsentinel.com (Christopher Fowler)</li></ul></li>
</ul></li></ul>
<!--X-Follow-Ups-End-->
<!--X-References-->
<!--X-References-End-->
<!--X-BotPNI-->
<ul>
<li>Prev by Date:
<strong><a href="msg01065.html">[ale] Critters in the Attic</a></strong>
</li>
<li>Next by Date:
<strong><a href="msg01067.html">[ale] Critters in the Attic</a></strong>
</li>
<li>Previous by thread:
<strong><a href="msg01070.html">[ale] Subversion usage</a></strong>
</li>
<li>Next by thread:
<strong><a href="msg01068.html">[ale] Pyhon syntax</a></strong>
</li>
<li>Index(es):
<ul>
<li><a href="maillist.html#01066"><strong>Date</strong></a></li>
<li><a href="threads.html#01066"><strong>Thread</strong></a></li>
</ul>
</li>
</ul>
<!--X-BotPNI-End-->
<!--X-User-Footer-->
<!--X-User-Footer-End-->
</body>
</html>