[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[no subject]



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>